From 90b48c2c48e2056a93b2619b94518769e6cefc9f Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 8 Jul 2019 14:15:48 -0300 Subject: [PATCH] Bug 23281: Implement ->search_with_library_limits in Koha::Patron::Attribute::Types This patch makes Koha::Patron::Attribute::Types inherit from Koha::Objects::Limit::Library so it now has the ->search_with_library_limits method. Tests are adjusted so it is clear that there is no behaviour change compared to the (previsouly) called ->search To test: - Run: k$ prove t/db_dependent/Koha/Patron/Attribute/Types.t => SUCCESS: Tests pass! - Apply this patch - Run: k$ prove t/db_dependent/Koha/Patron/Attribute/Types.t => SUCCESS: Tests still pass! - Sign off :-D Signed-off-by: Kyle M Hall Signed-off-by: Katrin Fischer Signed-off-by: Martin Renvoize --- Koha/Patron/Attribute/Types.pm | 2 +- t/db_dependent/Koha/Patron/Attribute/Types.t | 16 +++++----------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Koha/Patron/Attribute/Types.pm b/Koha/Patron/Attribute/Types.pm index c32eb015a7..5064fd2479 100644 --- a/Koha/Patron/Attribute/Types.pm +++ b/Koha/Patron/Attribute/Types.pm @@ -19,7 +19,7 @@ use Modern::Perl; use Koha::Patron::Attribute::Type; -use base qw(Koha::Objects); +use base qw(Koha::Objects Koha::Objects::Limit::Library); =head1 NAME diff --git a/t/db_dependent/Koha/Patron/Attribute/Types.t b/t/db_dependent/Koha/Patron/Attribute/Types.t index 80378c594d..8c49a45474 100644 --- a/t/db_dependent/Koha/Patron/Attribute/Types.t +++ b/t/db_dependent/Koha/Patron/Attribute/Types.t @@ -287,7 +287,7 @@ subtest 'replace_library_limits() tests' => sub { $schema->storage->txn_rollback; }; -subtest 'search() with branch limits tests' => sub { +subtest 'search_with_library_limits() tests' => sub { plan tests => 3; @@ -322,16 +322,10 @@ subtest 'search() with branch limits tests' => sub { $object_code_2->library_limits( [$branch_2] ); $object_code_3->library_limits( [ $branch_1, $branch_2 ] ); - is( Koha::Patron::Attribute::Types->search( { branchcode => $branch_1 } ) - ->count, - 3, - '3 attribute types are available for the specified branch' - ); - is( Koha::Patron::Attribute::Types->search( { branchcode => $branch_2 } ) - ->count, - 3, - '3 attribute types are available for the specified branch' - ); + is( Koha::Patron::Attribute::Types->search_with_library_limits( {}, {}, $branch_1 )->count, + 3, '3 attribute types are available for the specified branch' ); + is( Koha::Patron::Attribute::Types->search_with_library_limits( {}, {}, $branch_2 )->count, + 3, '3 attribute types are available for the specified branch' ); $schema->storage->txn_rollback; }; -- 2.39.5