Lines 385-400
subtest "to_api() tests" => sub {
Link Here
|
385 |
|
385 |
|
386 |
my $patron_api = $patron->to_api( |
386 |
my $patron_api = $patron->to_api( |
387 |
{ |
387 |
{ |
388 |
embed => { holds_count => { is_count => 1 } } |
388 |
embed => { holds_count => { is_count => 1 } }, |
|
|
389 |
user => $patron |
389 |
} |
390 |
} |
390 |
); |
391 |
); |
391 |
is( $patron_api->{holds_count}, $patron->holds->count, 'Count embeds are supported and work as expected' ); |
392 |
is( $patron_api->{holds_count}, $patron->holds->count, 'Count embeds are supported and work as expected' ); |
392 |
|
393 |
|
393 |
throws_ok |
394 |
throws_ok { |
394 |
{ |
395 |
$patron->to_api( { embed => { holds_count => {} }, user => $patron } ); |
395 |
$patron->to_api({ embed => { holds_count => {} } }); |
396 |
} |
396 |
} |
397 |
'Koha::Exceptions::Object::MethodNotCoveredByTests', |
397 |
'Koha::Exceptions::Object::MethodNotCoveredByTests', |
|
|
398 |
'Unknown method exception thrown if is_count not specified'; |
398 |
'Unknown method exception thrown if is_count not specified'; |
399 |
|
399 |
|
400 |
subtest 'unprivileged request tests' => sub { |
400 |
subtest 'unprivileged request tests' => sub { |
Lines 564-571
subtest "to_api() tests" => sub {
Link Here
|
564 |
|
564 |
|
565 |
t::lib::Mocks::mock_userenv( { patron => $patron } ); |
565 |
t::lib::Mocks::mock_userenv( { patron => $patron } ); |
566 |
|
566 |
|
567 |
is( ref($patron_1->to_api), 'HASH', 'Returns the object hash' ); |
567 |
is( ref($patron_1->to_api({ user => $patron })), 'HASH', 'Returns the object hash' ); |
568 |
is( $patron_2->to_api, undef, 'Not accessible, returns undef' ); |
568 |
is( $patron_2->to_api({ user => $patron }), undef, 'Not accessible, returns undef' ); |
569 |
|
569 |
|
570 |
$schema->storage->txn_rollback; |
570 |
$schema->storage->txn_rollback; |
571 |
}; |
571 |
}; |
Lines 1156-1162
subtest 'messages() and add_message() tests' => sub {
Link Here
|
1156 |
$schema->storage->txn_rollback; |
1156 |
$schema->storage->txn_rollback; |
1157 |
}; |
1157 |
}; |
1158 |
|
1158 |
|
1159 |
subtest 'accessible() tests' => sub { |
1159 |
subtest 'is_accessible() tests' => sub { |
1160 |
|
1160 |
|
1161 |
plan tests => 2; |
1161 |
plan tests => 2; |
1162 |
|
1162 |
|
Lines 1184-1191
subtest 'accessible() tests' => sub {
Link Here
|
1184 |
|
1184 |
|
1185 |
t::lib::Mocks::mock_userenv( { patron => $patron } ); |
1185 |
t::lib::Mocks::mock_userenv( { patron => $patron } ); |
1186 |
|
1186 |
|
1187 |
ok( $patron_1->accessible, 'Has access to the patron' ); |
1187 |
ok( $patron_1->is_accessible( { user => $patron } ), 'Has access to the patron' ); |
1188 |
ok( !$patron_2->accessible, 'Does not have access to the patron' ); |
1188 |
ok( !$patron_2->is_accessible( { user => $patron } ), 'Does not have access to the patron' ); |
1189 |
|
1189 |
|
1190 |
$schema->storage->txn_rollback; |
1190 |
$schema->storage->txn_rollback; |
1191 |
}; |
1191 |
}; |
1192 |
- |
|
|