Bug 19301: (QA follow-up) Add a few simple tests
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Fri, 22 Dec 2017 09:08:07 +0000 (10:08 +0100)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 13 Feb 2018 16:36:01 +0000 (13:36 -0300)
We removed tests from Reserves.t, but would be nice to test the new
sub in IssuingRules.t too.
Adding a subtest there.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
t/db_dependent/Koha/IssuingRules.t

index b1c97bf..66e2836 100644 (file)
@@ -19,7 +19,7 @@
 
 use Modern::Perl;
 
-use Test::More tests => 2;
+use Test::More tests => 3;
 
 use Benchmark;
 
@@ -290,6 +290,22 @@ subtest 'get_opacitemholds_policy' => sub {
     $patron->delete;
 };
 
+subtest 'get_onshelfholds_policy' => sub {
+    plan tests => 3;
+
+    t::lib::Mocks::mock_preference('item-level_itypes', 1);
+    Koha::IssuingRules->delete;
+
+    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
+    my $item = $builder->build_object({ class => 'Koha::Items' });
+
+    is( Koha::IssuingRules->get_onshelfholds_policy({ item => $item, patron => $patron }), undef, 'Should return undef when no rules can be found' );
+    Koha::IssuingRule->new({ categorycode => $patron->categorycode, itemtype => $item->itype, branchcode => '*', onshelfholds => "0" })->store;
+    is( Koha::IssuingRules->get_onshelfholds_policy({ item => $item, patron => $patron }), 0, 'Should be zero' );
+    Koha::IssuingRule->new({ categorycode => $patron->categorycode, itemtype => $item->itype, branchcode => $item->holdingbranch, onshelfholds => "2" })->store;
+    is( Koha::IssuingRules->get_onshelfholds_policy({ item => $item, patron => $patron }), 2, 'Should be two now' );
+};
+
 sub _row_match {
     my ($rule, $branchcode, $categorycode, $itemtype) = @_;