Lines 361-374
subtest "to_api() tests" => sub {
Link Here
|
361 |
|
361 |
|
362 |
my $patron_api = $patron->to_api( |
362 |
my $patron_api = $patron->to_api( |
363 |
{ |
363 |
{ |
364 |
embed => { holds_count => { is_count => 1 } } |
364 |
embed => { holds_count => { is_count => 1 } }, |
|
|
365 |
user => $patron |
365 |
} |
366 |
} |
366 |
); |
367 |
); |
367 |
is( $patron_api->{holds_count}, $patron->holds->count, 'Count embeds are supported and work as expected' ); |
368 |
is( $patron_api->{holds_count}, $patron->holds->count, 'Count embeds are supported and work as expected' ); |
368 |
|
369 |
|
369 |
throws_ok |
370 |
throws_ok |
370 |
{ |
371 |
{ |
371 |
$patron->to_api({ embed => { holds_count => {} } }); |
372 |
$patron->to_api({ embed => { holds_count => {} }, user => $patron }); |
372 |
} |
373 |
} |
373 |
'Koha::Exceptions::Object::MethodNotCoveredByTests', |
374 |
'Koha::Exceptions::Object::MethodNotCoveredByTests', |
374 |
'Unknown method exception thrown if is_count not specified'; |
375 |
'Unknown method exception thrown if is_count not specified'; |
Lines 448-455
subtest "to_api() tests" => sub {
Link Here
|
448 |
|
449 |
|
449 |
t::lib::Mocks::mock_userenv( { patron => $patron } ); |
450 |
t::lib::Mocks::mock_userenv( { patron => $patron } ); |
450 |
|
451 |
|
451 |
is( ref($patron_1->to_api), 'HASH', 'Returns the object hash' ); |
452 |
is( ref($patron_1->to_api({ user => $patron })), 'HASH', 'Returns the object hash' ); |
452 |
is( $patron_2->to_api, undef, 'Not accessible, returns undef' ); |
453 |
is( $patron_2->to_api({ user => $patron }), undef, 'Not accessible, returns undef' ); |
453 |
|
454 |
|
454 |
$schema->storage->txn_rollback; |
455 |
$schema->storage->txn_rollback; |
455 |
}; |
456 |
}; |
Lines 1031-1037
subtest 'messages() and add_message() tests' => sub {
Link Here
|
1031 |
$schema->storage->txn_rollback; |
1032 |
$schema->storage->txn_rollback; |
1032 |
}; |
1033 |
}; |
1033 |
|
1034 |
|
1034 |
subtest 'accessible() tests' => sub { |
1035 |
subtest 'is_accessible() tests' => sub { |
1035 |
|
1036 |
|
1036 |
plan tests => 2; |
1037 |
plan tests => 2; |
1037 |
|
1038 |
|
Lines 1059-1066
subtest 'accessible() tests' => sub {
Link Here
|
1059 |
|
1060 |
|
1060 |
t::lib::Mocks::mock_userenv( { patron => $patron } ); |
1061 |
t::lib::Mocks::mock_userenv( { patron => $patron } ); |
1061 |
|
1062 |
|
1062 |
ok( $patron_1->accessible, 'Has access to the patron' ); |
1063 |
ok( $patron_1->is_accessible({ user => $patron }), 'Has access to the patron' ); |
1063 |
ok( !$patron_2->accessible, 'Does not have access to the patron' ); |
1064 |
ok( !$patron_2->is_accessible({ user => $patron }), 'Does not have access to the patron' ); |
1064 |
|
1065 |
|
1065 |
$schema->storage->txn_rollback; |
1066 |
$schema->storage->txn_rollback; |
1066 |
}; |
1067 |
}; |
1067 |
- |
|
|