Browse Source

Bug 24083: Add unit tests

This patch adds unit tests for unseen renewals

Signed-off-by: Sally Healey <sally.Healey@cheshirewestandchester.gov.uk>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
20.11.x
Andrew Isherwood 2 years ago
committed by Jonathan Druart
parent
commit
b2110746d4
  1. 8
      t/db_dependent/Circulation.t
  2. 15
      t/db_dependent/Circulation/issue.t

8
t/db_dependent/Circulation.t

@ -1163,6 +1163,14 @@ subtest "CanBookBeRenewed tests" => sub {
is( $renewokay, 0, 'Cannot renew, 0 renewals allowed');
is( $error, 'too_many', 'Cannot renew, 0 renewals allowed (returned code is too_many)');
# Too many unseen renewals
$dbh->do('UPDATE issuingrules SET unseen_renewals_allowed = 2, renewalsallowed = 10');
$dbh->do('UPDATE issues SET unseen_renewals = 2 where borrowernumber = ? AND itemnumber = ?', undef, ($renewing_borrowernumber, $item_1->itemnumber));
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber);
is( $renewokay, 0, 'Cannot renew, 0 unseen renewals allowed');
is( $error, 'too_unseen', 'Cannot renew, returned code is too_unseen');
$dbh->do('UPDATE issuingrules SET norenewalbefore = NULL, renewalsallowed = 0');
# Test WhenLostForgiveFine and WhenLostChargeReplacementFee
t::lib::Mocks::mock_preference('WhenLostForgiveFine','1');
t::lib::Mocks::mock_preference('WhenLostChargeReplacementFee','1');

15
t/db_dependent/Circulation/issue.t

@ -32,6 +32,7 @@ use Koha::Checkouts;
use Koha::Database;
use Koha::DateUtils;
use Koha::Holds;
use Koha::IssuingRules;
use Koha::Items;
use Koha::Library;
use Koha::Patrons;
@ -297,6 +298,20 @@ subtest 'Show that AddRenewal respects OpacRenewalBranch and interface' => sub {
}
};
# Unseen rewnewals
t::lib::Mocks::mock_preference('UnseenRenewals', 1);
# Does an unseen renewal increment the issue's count
my ( $unseen_before ) = ( C4::Circulation::GetRenewCount( $opac_renew_issue->{borrowernumber}, $opac_renew_issue->{itemnumber} ) )[3];
AddRenewal( $opac_renew_issue->{borrowernumber}, $opac_renew_issue->{itemnumber}, $branchcode_1, undef, undef, 0 );
my ( $unseen_after ) = ( C4::Circulation::GetRenewCount( $opac_renew_issue->{borrowernumber}, $opac_renew_issue->{itemnumber} ) )[3];
is( $unseen_after, $unseen_before + 1, 'unseen_renewals increments' );
# Does a seen renewal reset the unseen count
AddRenewal( $opac_renew_issue->{borrowernumber}, $opac_renew_issue->{itemnumber}, $branchcode_1, undef, undef, 1 );
my ( $unseen_reset ) = ( C4::Circulation::GetRenewCount( $opac_renew_issue->{borrowernumber}, $opac_renew_issue->{itemnumber} ) )[3];
is( $unseen_reset, 0, 'seen renewal resets the unseen count' );
#Test GetBiblioIssues
is( GetBiblioIssues(), undef, "GetBiblio Issues without parameters" );

Loading…
Cancel
Save