Bug 11577: Unit tests
This patch fixes two unit tests that broke because of the new feature. Also adds some new test cases. To test: 1) prove t/db_dependent/Circulation.t 2) prove t/db_dependent/Circulation_Issuingrule.t Sponsored-by: Hochschule für Gesundheit (hsg), Germany Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
This commit is contained in:
parent
d02f87a298
commit
904b35645c
|
|
@ -26,7 +26,7 @@ use C4::Reserves;
|
|||
use Koha::DateUtils;
|
||||
use Koha::Database;
|
||||
|
||||
use Test::More tests => 51;
|
||||
use Test::More tests => 55;
|
||||
|
||||
BEGIN {
|
||||
use_ok('C4::Circulation');
|
||||
|
|
@ -151,10 +151,12 @@ $dbh->do(
|
|||
q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed,
|
||||
maxissueqty, issuelength, lengthunit,
|
||||
renewalsallowed, renewalperiod,
|
||||
norenewalbefore, auto_renew,
|
||||
fine, chargeperiod)
|
||||
VALUES (?, ?, ?, ?,
|
||||
?, ?, ?,
|
||||
?, ?,
|
||||
?, ?,
|
||||
?, ?
|
||||
)
|
||||
},
|
||||
|
|
@ -162,6 +164,7 @@ $dbh->do(
|
|||
'*', '*', '*', 25,
|
||||
20, 14, 'days',
|
||||
1, 7,
|
||||
'', 0,
|
||||
.10, 1
|
||||
);
|
||||
|
||||
|
|
@ -323,6 +326,25 @@ C4::Context->dbh->do("DELETE FROM accountlines");
|
|||
$reserveid = C4::Reserves::GetReserveId({ biblionumber => $biblionumber, itemnumber => $itemnumber, borrowernumber => $reserving_borrowernumber});
|
||||
CancelReserve({ reserve_id => $reserveid });
|
||||
|
||||
# Test automatic renewal before value for "norenewalbefore" in policy is set
|
||||
my $barcode4 = '11235813';
|
||||
my ( $item_bibnum4, $item_bibitemnum4, $itemnumber4 ) = AddItem(
|
||||
{
|
||||
homebranch => $branch,
|
||||
holdingbranch => $branch,
|
||||
barcode => $barcode4,
|
||||
replacementprice => 16.00
|
||||
},
|
||||
$biblionumber
|
||||
);
|
||||
|
||||
AddIssue( $renewing_borrower, $barcode4, undef, undef, undef, undef, 1 );
|
||||
( $renewokay, $error ) =
|
||||
CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 );
|
||||
is( $renewokay, 0, 'Cannot renew, renewal is automatic' );
|
||||
is( $error, 'auto_renew',
|
||||
'Cannot renew, renewal is automatic (returned code is auto_renew)' );
|
||||
|
||||
# set policy to require that loans cannot be
|
||||
# renewed until seven days prior to the due date
|
||||
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7');
|
||||
|
|
@ -335,6 +357,14 @@ C4::Context->dbh->do("DELETE FROM accountlines");
|
|||
'renewals permitted 7 days before due date, as expected',
|
||||
);
|
||||
|
||||
# Test automatic renewal again
|
||||
( $renewokay, $error ) =
|
||||
CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 );
|
||||
is( $renewokay, 0, 'Cannot renew, renewal is automatic and premature' );
|
||||
is( $error, 'auto_too_soon',
|
||||
'Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)'
|
||||
);
|
||||
|
||||
# Too many renewals
|
||||
|
||||
# set policy to forbid renewals
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ my $sampleissuingrule1 = {
|
|||
lengthunit => 'Null',
|
||||
renewalperiod => 5,
|
||||
norenewalbefore => 6,
|
||||
auto_renew => 0,
|
||||
issuelength => 5,
|
||||
chargeperiod => 0,
|
||||
rentaldiscount => '2.000000',
|
||||
|
|
@ -140,6 +141,7 @@ my $sampleissuingrule2 = {
|
|||
renewalsallowed => 'Null',
|
||||
renewalperiod => 2,
|
||||
norenewalbefore => 7,
|
||||
auto_renew => 0,
|
||||
reservesallowed => 'Null',
|
||||
issuelength => 2,
|
||||
lengthunit => 'Null',
|
||||
|
|
@ -165,6 +167,7 @@ my $sampleissuingrule3 = {
|
|||
renewalsallowed => 'Null',
|
||||
renewalperiod => 3,
|
||||
norenewalbefore => 8,
|
||||
auto_renew => 0,
|
||||
reservesallowed => 'Null',
|
||||
issuelength => 3,
|
||||
lengthunit => 'Null',
|
||||
|
|
@ -190,6 +193,7 @@ $query = 'INSERT INTO issuingrules (
|
|||
renewalsallowed,
|
||||
renewalperiod,
|
||||
norenewalbefore,
|
||||
auto_renew,
|
||||
reservesallowed,
|
||||
issuelength,
|
||||
lengthunit,
|
||||
|
|
@ -206,7 +210,7 @@ $query = 'INSERT INTO issuingrules (
|
|||
chargename,
|
||||
restrictedtype,
|
||||
maxsuspensiondays
|
||||
) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)';
|
||||
) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)';
|
||||
my $sth = $dbh->prepare($query);
|
||||
$sth->execute(
|
||||
$sampleissuingrule1->{branchcode},
|
||||
|
|
@ -216,6 +220,7 @@ $sth->execute(
|
|||
$sampleissuingrule1->{renewalsallowed},
|
||||
$sampleissuingrule1->{renewalperiod},
|
||||
$sampleissuingrule1->{norenewalbefore},
|
||||
$sampleissuingrule1->{auto_renew},
|
||||
$sampleissuingrule1->{reservesallowed},
|
||||
$sampleissuingrule1->{issuelength},
|
||||
$sampleissuingrule1->{lengthunit},
|
||||
|
|
@ -241,6 +246,7 @@ $sth->execute(
|
|||
$sampleissuingrule2->{renewalsallowed},
|
||||
$sampleissuingrule2->{renewalperiod},
|
||||
$sampleissuingrule2->{norenewalbefore},
|
||||
$sampleissuingrule1->{auto_renew},
|
||||
$sampleissuingrule2->{reservesallowed},
|
||||
$sampleissuingrule2->{issuelength},
|
||||
$sampleissuingrule2->{lengthunit},
|
||||
|
|
@ -266,6 +272,7 @@ $sth->execute(
|
|||
$sampleissuingrule3->{renewalsallowed},
|
||||
$sampleissuingrule3->{renewalperiod},
|
||||
$sampleissuingrule3->{norenewalbefore},
|
||||
$sampleissuingrule1->{auto_renew},
|
||||
$sampleissuingrule3->{reservesallowed},
|
||||
$sampleissuingrule3->{issuelength},
|
||||
$sampleissuingrule3->{lengthunit},
|
||||
|
|
|
|||
Loading…
Reference in New Issue