Lines 226-232
subtest 'TO_JSON tests' => sub {
Link Here
|
226 |
|
226 |
|
227 |
subtest "to_api() tests" => sub { |
227 |
subtest "to_api() tests" => sub { |
228 |
|
228 |
|
229 |
plan tests => 31; |
229 |
plan tests => 32; |
230 |
|
230 |
|
231 |
$schema->storage->txn_begin; |
231 |
$schema->storage->txn_begin; |
232 |
|
232 |
|
Lines 536-541
subtest "to_api() tests" => sub {
Link Here
|
536 |
$schema->storage->txn_rollback; |
536 |
$schema->storage->txn_rollback; |
537 |
}; |
537 |
}; |
538 |
|
538 |
|
|
|
539 |
subtest 'accessible usage tests' => sub { |
540 |
|
541 |
plan tests => 2; |
542 |
|
543 |
$schema->storage->txn_begin; |
544 |
|
545 |
my $library_1 = $builder->build_object( { class => 'Koha::Libraries' } ); |
546 |
my $library_2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
547 |
|
548 |
my $patron = $builder->build_object( |
549 |
{ |
550 |
class => 'Koha::Patrons', |
551 |
value => { |
552 |
flags => 2**2, # only has catalogue permissions |
553 |
branchcode => $library_1->id |
554 |
} |
555 |
} |
556 |
); |
557 |
|
558 |
|
559 |
my $patron_1 = $builder->build_object( |
560 |
{ class => 'Koha::Patrons', value => { branchcode => $library_1->id } } |
561 |
); |
562 |
my $patron_2 = $builder->build_object( |
563 |
{ class => 'Koha::Patrons', value => { branchcode => $library_2->id } } |
564 |
); |
565 |
|
566 |
t::lib::Mocks::mock_userenv( { patron => $patron } ); |
567 |
|
568 |
is( ref($patron_1->to_api), 'HASH', 'Returns the object hash' ); |
569 |
is( $patron_2->to_api, undef, 'Not accessible, returns undef' ); |
570 |
|
571 |
$schema->storage->txn_rollback; |
572 |
}; |
573 |
|
539 |
$schema->storage->txn_rollback; |
574 |
$schema->storage->txn_rollback; |
540 |
}; |
575 |
}; |
541 |
|
576 |
|
542 |
- |
|
|