|
Lines 339-345
subtest 'AddIssue | renewal when adding issue to same borrower' => sub {
Link Here
|
| 339 |
my $staff = $builder->build_object( { class => "Koha::Patrons" } ); |
339 |
my $staff = $builder->build_object( { class => "Koha::Patrons" } ); |
| 340 |
t::lib::Mocks::mock_userenv( { patron => $staff } ); |
340 |
t::lib::Mocks::mock_userenv( { patron => $staff } ); |
| 341 |
|
341 |
|
| 342 |
t::lib::Mocks::mock_preference( 'RenewalPeriodBase', 'date_due' ); |
342 |
t::lib::Mocks::mock_preference( 'ManualRenewalPeriodBase', 'date_due' ); |
| 343 |
|
343 |
|
| 344 |
my $issue = AddIssue( $patron, $item->barcode ); |
344 |
my $issue = AddIssue( $patron, $item->barcode ); |
| 345 |
is( dt_from_string( $issue->date_due )->truncate( to => 'day' ), $seven_days, "Item issued for correct term" ); |
345 |
is( dt_from_string( $issue->date_due )->truncate( to => 'day' ), $seven_days, "Item issued for correct term" ); |
|
Lines 866-872
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 866 |
|
866 |
|
| 867 |
# Calculate new due-date based on the present date not to incur |
867 |
# Calculate new due-date based on the present date not to incur |
| 868 |
# multiple fees |
868 |
# multiple fees |
| 869 |
t::lib::Mocks::mock_preference( 'RenewalPeriodBase', 'now' ); |
869 |
t::lib::Mocks::mock_preference( 'ManualRenewalPeriodBase', 'now' ); |
| 870 |
|
870 |
|
| 871 |
my $staff = $builder->build_object( { class => "Koha::Patrons" } ); |
871 |
my $staff = $builder->build_object( { class => "Koha::Patrons" } ); |
| 872 |
t::lib::Mocks::mock_userenv( { patron => $staff } ); |
872 |
t::lib::Mocks::mock_userenv( { patron => $staff } ); |
|
Lines 1905-1912
subtest "CanBookBeRenewed | bookings" => sub {
Link Here
|
| 1905 |
my $schema = Koha::Database->schema; |
1905 |
my $schema = Koha::Database->schema; |
| 1906 |
$schema->storage->txn_begin; |
1906 |
$schema->storage->txn_begin; |
| 1907 |
|
1907 |
|
| 1908 |
t::lib::Mocks::mock_preference( 'RenewalPeriodBase', 'date_due' ); |
1908 |
t::lib::Mocks::mock_preference( 'ManualRenewalPeriodBase', 'date_due' ); |
| 1909 |
t::lib::Mocks::mock_preference( 'ChildNeedsGuarantor', 0 ); |
1909 |
t::lib::Mocks::mock_preference( 'ChildNeedsGuarantor', 0 ); |
| 1910 |
|
1910 |
|
| 1911 |
my $renewing_patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
1911 |
my $renewing_patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 1912 |
my $booked_patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
1912 |
my $booked_patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
|
Lines 7515-7520
subtest 'Test CanBookBeIssued param ignore_reserves (Bug 35322)' => sub {
Link Here
|
| 7515 |
|
7515 |
|
| 7516 |
}; |
7516 |
}; |
| 7517 |
|
7517 |
|
|
|
7518 |
subtest "Check AutomaticRenewalPeriodBase vs ManualRenewalPeriodBase ( Bug 30331 )" => sub { |
| 7519 |
plan tests => 4; |
| 7520 |
|
| 7521 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 7522 |
my $patron = |
| 7523 |
$builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library->branchcode } } ); |
| 7524 |
my $item = $builder->build_sample_item( { library => $library->branchcode } ); |
| 7525 |
my $staff = $builder->build_object( { class => "Koha::Patrons" } ); |
| 7526 |
t::lib::Mocks::mock_userenv( { patron => $staff, branchcode => $library->branchcode } ); |
| 7527 |
|
| 7528 |
Koha::CirculationRules->set_rules( |
| 7529 |
{ |
| 7530 |
categorycode => undef, |
| 7531 |
branchcode => undef, |
| 7532 |
itemtype => $item->effective_itemtype, |
| 7533 |
rules => { |
| 7534 |
issuelength => 14, |
| 7535 |
lengthunit => 'days', |
| 7536 |
renewalperiod => 7, |
| 7537 |
renewalsallowed => 5, |
| 7538 |
} |
| 7539 |
} |
| 7540 |
); |
| 7541 |
|
| 7542 |
#Manual renewal with ManualRenewalPeriodBase === 'date_due' |
| 7543 |
t::lib::Mocks::mock_preference( 'ManualRenewalPeriodBase', 'date_due' ); |
| 7544 |
t::lib::Mocks::mock_preference( 'AutomaticRenewalPeriodBase', 'now' ); |
| 7545 |
|
| 7546 |
my $issue = AddIssue( $patron, $item->barcode ); |
| 7547 |
my $original_due = dt_from_string( $issue->date_due ); |
| 7548 |
my $expected_due = $original_due->clone()->add( days => 7 ); |
| 7549 |
|
| 7550 |
my $manual_due = AddRenewal( |
| 7551 |
{ |
| 7552 |
borrowernumber => $patron->borrowernumber, |
| 7553 |
itemnumber => $item->itemnumber, |
| 7554 |
branch => $library->branchcode, |
| 7555 |
automatic => 0, |
| 7556 |
} |
| 7557 |
); |
| 7558 |
|
| 7559 |
is( |
| 7560 |
$manual_due->truncate( to => 'day' )->ymd, |
| 7561 |
$expected_due->truncate( to => 'day' )->ymd, |
| 7562 |
'Manual renewal based off of old due date' |
| 7563 |
); |
| 7564 |
|
| 7565 |
#Manual renewal with ManualRenewalPeriodBase === 'now' |
| 7566 |
t::lib::Mocks::mock_preference( 'ManualRenewalPeriodBase', 'now' ); |
| 7567 |
|
| 7568 |
$issue = Koha::Checkouts->find( { itemnumber => $item->itemnumber } ); |
| 7569 |
my $now = dt_from_string(); |
| 7570 |
$expected_due = $now->clone()->add( days => 7 ); |
| 7571 |
|
| 7572 |
$manual_due = AddRenewal( |
| 7573 |
{ |
| 7574 |
borrowernumber => $patron->borrowernumber, |
| 7575 |
itemnumber => $item->itemnumber, |
| 7576 |
branch => $library->branchcode, |
| 7577 |
automatic => 0, |
| 7578 |
} |
| 7579 |
); |
| 7580 |
|
| 7581 |
is( |
| 7582 |
$manual_due->truncate( to => 'day' )->ymd, |
| 7583 |
$expected_due->truncate( to => 'day' )->ymd, |
| 7584 |
'Manual renewal based off of current date' |
| 7585 |
); |
| 7586 |
|
| 7587 |
#Automatic renewal with AutomaticRenewalPeriodBase === 'date_due' |
| 7588 |
t::lib::Mocks::mock_preference( 'ManualRenewalPeriodBase', 'now' ); |
| 7589 |
t::lib::Mocks::mock_preference( 'AutomaticRenewalPeriodBase', 'date_due' ); |
| 7590 |
|
| 7591 |
$issue = Koha::Checkouts->find( { itemnumber => $item->itemnumber } ); |
| 7592 |
$original_due = dt_from_string( $issue->date_due ); |
| 7593 |
$expected_due = $original_due->clone()->add( days => 7 ); |
| 7594 |
|
| 7595 |
my $auto_due = AddRenewal( |
| 7596 |
{ |
| 7597 |
borrowernumber => $patron->borrowernumber, |
| 7598 |
itemnumber => $item->itemnumber, |
| 7599 |
branch => $library->branchcode, |
| 7600 |
automatic => 1, |
| 7601 |
} |
| 7602 |
); |
| 7603 |
|
| 7604 |
is( |
| 7605 |
$auto_due->truncate( to => 'day' )->ymd, |
| 7606 |
$expected_due->truncate( to => 'day' )->ymd, |
| 7607 |
'Automatic renewal uses old checkout date' |
| 7608 |
); |
| 7609 |
|
| 7610 |
#Automatic renewal with AutomaticRenewalPeriodBase === 'now' |
| 7611 |
t::lib::Mocks::mock_preference( 'ManualRenewalPeriodBase', 'date_due' ); |
| 7612 |
t::lib::Mocks::mock_preference( 'AutomaticRenewalPeriodBase', 'now' ); |
| 7613 |
|
| 7614 |
$issue = Koha::Checkouts->find( { itemnumber => $item->itemnumber } ); |
| 7615 |
$now = dt_from_string(); |
| 7616 |
$expected_due = $now->clone()->add( days => 7 ); |
| 7617 |
|
| 7618 |
$auto_due = AddRenewal( |
| 7619 |
{ |
| 7620 |
borrowernumber => $patron->borrowernumber, |
| 7621 |
itemnumber => $item->itemnumber, |
| 7622 |
branch => $library->branchcode, |
| 7623 |
automatic => 1, |
| 7624 |
} |
| 7625 |
); |
| 7626 |
|
| 7627 |
is( |
| 7628 |
$auto_due->truncate( to => 'day' )->ymd, |
| 7629 |
$expected_due->truncate( to => 'day' )->ymd, |
| 7630 |
'Automatic renewal uses current date' |
| 7631 |
); |
| 7632 |
}; |
| 7633 |
|
| 7518 |
subtest 'NoRefundOnLostFinesPaidAge' => sub { |
7634 |
subtest 'NoRefundOnLostFinesPaidAge' => sub { |
| 7519 |
plan tests => 2; |
7635 |
plan tests => 2; |
| 7520 |
|
7636 |
|
| 7521 |
- |
|
|