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

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2016-11-07 15:47:43 +00:00 committed by Kyle M Hall
parent 1da4a7b4a2
commit 81ea88fff6
2 changed files with 32 additions and 1 deletions

View File

@ -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();

View File

@ -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' );