From 2f52f56e0bf2568b75ecc288bd87d4c261d6b356 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 7 Nov 2016 15:47:43 +0000 Subject: [PATCH] Bug 17604: GetMemberDetails - Add Koha::Patron::Category->effective_BlockExpiredPatronOpacActions This patch simply adds a new method to retrieve the correct value of BlockExpiredPatronOpacActions. Test plan: prove t/db_dependent/Koha/Patron/Categories.t should return green --- Koha/Patron/Category.pm | 14 ++++++++++++++ t/db_dependent/Koha/Patron/Categories.t | 19 ++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Koha/Patron/Category.pm b/Koha/Patron/Category.pm index 7b8c07e..b1244d5 100644 --- a/Koha/Patron/Category.pm +++ b/Koha/Patron/Category.pm @@ -36,6 +36,20 @@ Koha::Patron;;Category - Koha Patron;;Category Object class =cut +=head3 effective_BlockExpiredPatronOpacActions + +my $BlockExpiredPatronOpacActions = $category->effective_BlockExpiredPatronOpacActions + +Return the effective BlockExpiredPatronOpacActions value. + +=cut + +sub effective_BlockExpiredPatronOpacActions { + my( $self) = @_; + return C4::Context->preference('BlockExpiredPatronOpacActions') if $self->BlockExpiredPatronOpacActions == -1; + return $self->BlockExpiredPatronOpacActions +} + =head3 default_messaging my $messaging = $category->default_messaging(); diff --git a/t/db_dependent/Koha/Patron/Categories.t b/t/db_dependent/Koha/Patron/Categories.t index b47bcff..58670f7 100644 --- a/t/db_dependent/Koha/Patron/Categories.t +++ b/t/db_dependent/Koha/Patron/Categories.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 8; +use Test::More tests => 9; use C4::Context; use Koha::Database; @@ -27,6 +27,7 @@ use Koha::DateUtils; use Koha::Patron::Category; use Koha::Patron::Categories; use t::lib::TestBuilder; +use t::lib::Mocks; my $schema = Koha::Database->new->schema; $schema->storage->txn_begin; @@ -83,6 +84,22 @@ subtest 'get_expiry_date' => sub { $category->delete; }; +subtest 'BlockExpiredPatronOpacActions' => sub { + plan tests => 2; + t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 42); + my $category = Koha::Patron::Category->new({ + categorycode => 'ya_cat', + category_type => 'A', + description => 'yacatdesc', + enrolmentperiod => undef, + BlockExpiredPatronOpacActions => -1, + })->store; + is( $category->effective_BlockExpiredPatronOpacActions, 42 ); + $category->BlockExpiredPatronOpacActions(24)->store; + is( $category->effective_BlockExpiredPatronOpacActions, 24 ); + $category->delete; +}; + $retrieved_category_1->delete; is( Koha::Patron::Categories->search->count, $nb_of_categories + 1, 'Delete should have deleted the patron category' ); -- 2.1.4