From 3b3ec87d20a80b30ba014096ccc21af652aefb5a Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 19 Nov 2021 13:12:14 -0300 Subject: [PATCH] Bug 29523: Regression tests Signed-off-by: Tomas Cohen Arazi Signed-off-by: David Nind Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/Koha/Object.t | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/t/db_dependent/Koha/Object.t b/t/db_dependent/Koha/Object.t index d0f653bda7..91f14c7b80 100755 --- a/t/db_dependent/Koha/Object.t +++ b/t/db_dependent/Koha/Object.t @@ -473,6 +473,25 @@ subtest "to_api() tests" => sub { } ); + subtest 'accessible usage tests' => sub { + + plan tests => 2; + + $schema->storage->txn_begin; + + my $library_1 = $builder->build_object( { class => 'Koha::Libraries' } ); + my $library_2 = $builder->build_object( { class => 'Koha::Libraries' } ); + + my $patron = $builder->build_object( + { + class => 'Koha::Patrons', + value => { + flags => 2**2, # only has catalogue permissions + branchcode => $library_1->id + } + } + ); + my $city_mock = Test::MockModule->new('Koha::City'); $city_mock->mock( 'strings_map', @@ -533,6 +552,18 @@ subtest "to_api() tests" => sub { 'Authorised value for country expanded' ); + my $patron_1 = $builder->build_object( + { class => 'Koha::Patrons', value => { branchcode => $library_1->id } } + ); + my $patron_2 = $builder->build_object( + { class => 'Koha::Patrons', value => { branchcode => $library_2->id } } + ); + + t::lib::Mocks::mock_userenv( { patron => $patron } ); + + is( ref($patron_1->to_api), 'HASH', 'Returns the object hash' ); + is( $patron_2->to_api, undef, 'Not accessible, returns undef' ); + $schema->storage->txn_rollback; }; -- 2.40.0