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 565-572
subtest "to_api() tests" => sub {
Link Here
|
565 |
|
566 |
|
566 |
t::lib::Mocks::mock_userenv( { patron => $patron } ); |
567 |
t::lib::Mocks::mock_userenv( { patron => $patron } ); |
567 |
|
568 |
|
568 |
is( ref($patron_1->to_api), 'HASH', 'Returns the object hash' ); |
569 |
is( ref($patron_1->to_api({ user => $patron })), 'HASH', 'Returns the object hash' ); |
569 |
is( $patron_2->to_api, undef, 'Not accessible, returns undef' ); |
570 |
is( $patron_2->to_api({ user => $patron }), undef, 'Not accessible, returns undef' ); |
570 |
|
571 |
|
571 |
$schema->storage->txn_rollback; |
572 |
$schema->storage->txn_rollback; |
572 |
}; |
573 |
}; |
Lines 1148-1154
subtest 'messages() and add_message() tests' => sub {
Link Here
|
1148 |
$schema->storage->txn_rollback; |
1149 |
$schema->storage->txn_rollback; |
1149 |
}; |
1150 |
}; |
1150 |
|
1151 |
|
1151 |
subtest 'accessible() tests' => sub { |
1152 |
subtest 'is_accessible() tests' => sub { |
1152 |
|
1153 |
|
1153 |
plan tests => 2; |
1154 |
plan tests => 2; |
1154 |
|
1155 |
|
Lines 1176-1183
subtest 'accessible() tests' => sub {
Link Here
|
1176 |
|
1177 |
|
1177 |
t::lib::Mocks::mock_userenv( { patron => $patron } ); |
1178 |
t::lib::Mocks::mock_userenv( { patron => $patron } ); |
1178 |
|
1179 |
|
1179 |
ok( $patron_1->accessible, 'Has access to the patron' ); |
1180 |
ok( $patron_1->is_accessible({ user => $patron }), 'Has access to the patron' ); |
1180 |
ok( !$patron_2->accessible, 'Does not have access to the patron' ); |
1181 |
ok( !$patron_2->is_accessible({ user => $patron }), 'Does not have access to the patron' ); |
1181 |
|
1182 |
|
1182 |
$schema->storage->txn_rollback; |
1183 |
$schema->storage->txn_rollback; |
1183 |
}; |
1184 |
}; |
1184 |
- |
|
|