Bug 17604: GetMemberDetails - Add Koha::Patron::Category->effective_BlockExpiredPatro...
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 7 Nov 2016 15:47:43 +0000 (15:47 +0000)
committerKyle M Hall <kyle@bywatersolutions.com>
Tue, 15 Nov 2016 15:21:31 +0000 (15:21 +0000)
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>
Koha/Patron/Category.pm
t/db_dependent/Koha/Patron/Categories.t

index 7b8c07e..b1244d5 100644 (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();
index b47bcff..58670f7 100644 (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' );