@@ -, +, @@ Koha::Patron::Category->effective_BlockExpiredPatronOpacActions prove t/db_dependent/Koha/Patron/Categories.t --- Koha/Patron/Category.pm | 14 ++++++++++++++ t/db_dependent/Koha/Patron/Categories.t | 19 ++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) --- a/Koha/Patron/Category.pm +++ a/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(); --- a/t/db_dependent/Koha/Patron/Categories.t +++ a/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' ); --