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