Lines 386-399
subtest "to_api() tests" => sub {
Link Here
|
386 |
|
386 |
|
387 |
my $patron_api = $patron->to_api( |
387 |
my $patron_api = $patron->to_api( |
388 |
{ |
388 |
{ |
389 |
embed => { holds_count => { is_count => 1 } } |
389 |
embed => { holds_count => { is_count => 1 } }, |
|
|
390 |
user => $patron |
390 |
} |
391 |
} |
391 |
); |
392 |
); |
392 |
is( $patron_api->{holds_count}, $patron->holds->count, 'Count embeds are supported and work as expected' ); |
393 |
is( $patron_api->{holds_count}, $patron->holds->count, 'Count embeds are supported and work as expected' ); |
393 |
|
394 |
|
394 |
throws_ok |
395 |
throws_ok |
395 |
{ |
396 |
{ |
396 |
$patron->to_api({ embed => { holds_count => {} } }); |
397 |
$patron->to_api({ embed => { holds_count => {} }, user => $patron }); |
397 |
} |
398 |
} |
398 |
'Koha::Exceptions::Object::MethodNotCoveredByTests', |
399 |
'Koha::Exceptions::Object::MethodNotCoveredByTests', |
399 |
'Unknown method exception thrown if is_count not specified'; |
400 |
'Unknown method exception thrown if is_count not specified'; |
Lines 561-568
subtest "to_api() tests" => sub {
Link Here
|
561 |
|
562 |
|
562 |
t::lib::Mocks::mock_userenv( { patron => $patron } ); |
563 |
t::lib::Mocks::mock_userenv( { patron => $patron } ); |
563 |
|
564 |
|
564 |
is( ref($patron_1->to_api), 'HASH', 'Returns the object hash' ); |
565 |
is( ref($patron_1->to_api({ user => $patron })), 'HASH', 'Returns the object hash' ); |
565 |
is( $patron_2->to_api, undef, 'Not accessible, returns undef' ); |
566 |
is( $patron_2->to_api({ user => $patron }), undef, 'Not accessible, returns undef' ); |
566 |
|
567 |
|
567 |
$schema->storage->txn_rollback; |
568 |
$schema->storage->txn_rollback; |
568 |
}; |
569 |
}; |
Lines 1144-1150
subtest 'messages() and add_message() tests' => sub {
Link Here
|
1144 |
$schema->storage->txn_rollback; |
1145 |
$schema->storage->txn_rollback; |
1145 |
}; |
1146 |
}; |
1146 |
|
1147 |
|
1147 |
subtest 'accessible() tests' => sub { |
1148 |
subtest 'is_accessible() tests' => sub { |
1148 |
|
1149 |
|
1149 |
plan tests => 2; |
1150 |
plan tests => 2; |
1150 |
|
1151 |
|
Lines 1172-1179
subtest 'accessible() tests' => sub {
Link Here
|
1172 |
|
1173 |
|
1173 |
t::lib::Mocks::mock_userenv( { patron => $patron } ); |
1174 |
t::lib::Mocks::mock_userenv( { patron => $patron } ); |
1174 |
|
1175 |
|
1175 |
ok( $patron_1->accessible, 'Has access to the patron' ); |
1176 |
ok( $patron_1->is_accessible({ user => $patron }), 'Has access to the patron' ); |
1176 |
ok( !$patron_2->accessible, 'Does not have access to the patron' ); |
1177 |
ok( !$patron_2->is_accessible({ user => $patron }), 'Does not have access to the patron' ); |
1177 |
|
1178 |
|
1178 |
$schema->storage->txn_rollback; |
1179 |
$schema->storage->txn_rollback; |
1179 |
}; |
1180 |
}; |
1180 |
- |
|
|