Bug 14337: Add 2 more tests to be complete
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 25 Aug 2015 11:47:57 +0000 (12:47 +0100)
committerTomas Cohen Arazi <tomascohen@theke.io>
Fri, 28 Aug 2015 13:42:33 +0000 (10:42 -0300)
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
t/db_dependent/Circulation.t

index c1b4b08..591c7e4 100755 (executable)
@@ -27,7 +27,7 @@ use C4::Overdues qw(UpdateFine);
 use Koha::DateUtils;
 use Koha::Database;
 
-use Test::More tests => 65;
+use Test::More tests => 67;
 
 BEGIN {
     use_ok('C4::Circulation');
@@ -658,14 +658,25 @@ C4::Context->dbh->do("DELETE FROM accountlines");
         undef, undef, undef
     );
 
+    C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 0");
+    C4::Context->set_preference( 'AllowRenewalIfOtherItemsAvailable', 0 );
     ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 );
-    is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record' );
+    is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfholds are disabled' );
 
-    C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 1");
+    C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 0");
     C4::Context->set_preference( 'AllowRenewalIfOtherItemsAvailable', 1 );
+    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 );
+    is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled and onshelfholds is disabled' );
 
+    C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 1");
+    C4::Context->set_preference( 'AllowRenewalIfOtherItemsAvailable', 0 );
+    ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 );
+    is( $renewokay, 0, 'Bug 14337 - Verify the borrower cannot renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is disabled and onshelfhold is enabled' );
+
+    C4::Context->dbh->do("UPDATE issuingrules SET onshelfholds = 1");
+    C4::Context->set_preference( 'AllowRenewalIfOtherItemsAvailable', 1 );
     ( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $itemnumber1 );
-    is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled' );
+    is( $renewokay, 1, 'Bug 14337 - Verify the borrower can renew with a hold on the record if AllowRenewalIfOtherItemsAvailable and onshelfhold are enabled' );
 
     # Setting item not checked out to be not for loan but holdable
     ModItem({ notforloan => -1 }, $biblionumber, $itemnumber2);