Lines 71-78
sub test_debarment_on_checkout {
Link Here
|
71 |
my $item = $params->{item}; |
71 |
my $item = $params->{item}; |
72 |
my $library = $params->{library}; |
72 |
my $library = $params->{library}; |
73 |
my $patron = $params->{patron}; |
73 |
my $patron = $params->{patron}; |
74 |
my $due_date = $params->{due_date} || dt_from_string; |
74 |
my $due_date = $params->{due_date} || dt_from_string(); |
75 |
my $return_date = $params->{return_date} || dt_from_string; |
75 |
my $return_date = $params->{return_date} || dt_from_string(); |
76 |
my $expected_expiration_date = $params->{expiration_date}; |
76 |
my $expected_expiration_date = $params->{expiration_date}; |
77 |
|
77 |
|
78 |
$expected_expiration_date = output_pref( |
78 |
$expected_expiration_date = output_pref( |
Lines 105-111
my $builder = t::lib::TestBuilder->new;
Link Here
|
105 |
my $dbh = C4::Context->dbh; |
105 |
my $dbh = C4::Context->dbh; |
106 |
|
106 |
|
107 |
# Prevent random failures by mocking ->now |
107 |
# Prevent random failures by mocking ->now |
108 |
my $now_value = dt_from_string; |
108 |
my $now_value = dt_from_string(); |
109 |
my $mocked_datetime = Test::MockModule->new('DateTime'); |
109 |
my $mocked_datetime = Test::MockModule->new('DateTime'); |
110 |
$mocked_datetime->mock( 'now', sub { return $now_value->clone; } ); |
110 |
$mocked_datetime->mock( 'now', sub { return $now_value->clone; } ); |
111 |
|
111 |
|
Lines 2218-2224
subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
Link Here
|
2218 |
); |
2218 |
); |
2219 |
|
2219 |
|
2220 |
# Patron cannot issue item_1, they have overdues |
2220 |
# Patron cannot issue item_1, they have overdues |
2221 |
my $now = dt_from_string; |
2221 |
my $now = dt_from_string(); |
2222 |
my $five_days_ago = $now->clone->subtract( days => 5 ); |
2222 |
my $five_days_ago = $now->clone->subtract( days => 5 ); |
2223 |
my $ten_days_ago = $now->clone->subtract( days => 10 ); |
2223 |
my $ten_days_ago = $now->clone->subtract( days => 10 ); |
2224 |
AddIssue( $patron, $item_1->barcode, $five_days_ago ); # Add an overdue |
2224 |
AddIssue( $patron, $item_1->barcode, $five_days_ago ); # Add an overdue |
Lines 2324-2330
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
2324 |
} |
2324 |
} |
2325 |
); |
2325 |
); |
2326 |
|
2326 |
|
2327 |
my $now = dt_from_string; |
2327 |
my $now = dt_from_string(); |
2328 |
my $five_days_ago = $now->clone->subtract( days => 5 ); |
2328 |
my $five_days_ago = $now->clone->subtract( days => 5 ); |
2329 |
# We want to charge 2 days every day, without grace |
2329 |
# We want to charge 2 days every day, without grace |
2330 |
# With 5 days of overdue: 5 * Z |
2330 |
# With 5 days of overdue: 5 * Z |
Lines 2356-2362
subtest 'AddReturn + suspension_chargeperiod' => sub {
Link Here
|
2356 |
} |
2356 |
} |
2357 |
); |
2357 |
); |
2358 |
{ |
2358 |
{ |
2359 |
my $now = dt_from_string; |
2359 |
my $now = dt_from_string(); |
2360 |
my $five_days_ago = $now->clone->subtract( days => 5 ); |
2360 |
my $five_days_ago = $now->clone->subtract( days => 5 ); |
2361 |
# We want to charge 2 days every day, without grace |
2361 |
# We want to charge 2 days every day, without grace |
2362 |
# With 5 days of overdue: 5 * Z |
2362 |
# With 5 days of overdue: 5 * Z |
Lines 2603-2609
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2603 |
} |
2603 |
} |
2604 |
); |
2604 |
); |
2605 |
|
2605 |
|
2606 |
my $now = dt_from_string; |
2606 |
my $now = dt_from_string(); |
2607 |
my $one_day_ago = $now->clone->subtract( days => 1 ); |
2607 |
my $one_day_ago = $now->clone->subtract( days => 1 ); |
2608 |
my $two_days_ago = $now->clone->subtract( days => 2 ); |
2608 |
my $two_days_ago = $now->clone->subtract( days => 2 ); |
2609 |
my $five_days_ago = $now->clone->subtract( days => 5 ); |
2609 |
my $five_days_ago = $now->clone->subtract( days => 5 ); |
Lines 2799-2805
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2799 |
|
2799 |
|
2800 |
t::lib::Mocks::mock_preference( 'CalculateFinesOnBackdate', 1 ); |
2800 |
t::lib::Mocks::mock_preference( 'CalculateFinesOnBackdate', 1 ); |
2801 |
|
2801 |
|
2802 |
my $due_date = dt_from_string; |
2802 |
my $due_date = dt_from_string(); |
2803 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $due_date ); |
2803 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, $due_date ); |
2804 |
|
2804 |
|
2805 |
# Add fine |
2805 |
# Add fine |
Lines 3569-3575
subtest 'CanBookBeIssued | is_overdue' => sub {
Link Here
|
3569 |
} |
3569 |
} |
3570 |
); |
3570 |
); |
3571 |
|
3571 |
|
3572 |
my $now = dt_from_string; |
3572 |
my $now = dt_from_string(); |
3573 |
my $five_days_go = output_pref({ dt => $now->clone->add( days => 5 ), dateonly => 1}); |
3573 |
my $five_days_go = output_pref({ dt => $now->clone->add( days => 5 ), dateonly => 1}); |
3574 |
my $ten_days_go = output_pref({ dt => $now->clone->add( days => 10), dateonly => 1 }); |
3574 |
my $ten_days_go = output_pref({ dt => $now->clone->add( days => 10), dateonly => 1 }); |
3575 |
my $library = $builder->build( { source => 'Branch' } ); |
3575 |
my $library = $builder->build( { source => 'Branch' } ); |
Lines 3946-3952
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
Link Here
|
3946 |
$context = Test::MockModule->new('C4::Context'); |
3946 |
$context = Test::MockModule->new('C4::Context'); |
3947 |
$context->mock( userenv => { branch => undef, interface => 'CRON'} ); #Test statistical logging of renewal via cron (atuo_renew) |
3947 |
$context->mock( userenv => { branch => undef, interface => 'CRON'} ); #Test statistical logging of renewal via cron (atuo_renew) |
3948 |
|
3948 |
|
3949 |
my $now = dt_from_string; |
3949 |
my $now = dt_from_string(); |
3950 |
$date = output_pref( { dt => $now, dateonly => 1, dateformat => 'iso' } ); |
3950 |
$date = output_pref( { dt => $now, dateonly => 1, dateformat => 'iso' } ); |
3951 |
$old_log_size = Koha::ActionLogs->count( \%params_renewal ); |
3951 |
$old_log_size = Koha::ActionLogs->count( \%params_renewal ); |
3952 |
my $sth = $dbh->prepare("SELECT COUNT(*) FROM statistics WHERE itemnumber = ? AND branch = ?"); |
3952 |
my $sth = $dbh->prepare("SELECT COUNT(*) FROM statistics WHERE itemnumber = ? AND branch = ?"); |
Lines 4036-4042
subtest 'Incremented fee tests' => sub {
Link Here
|
4036 |
is( $item->effective_itemtype, $itemtype->id, |
4036 |
is( $item->effective_itemtype, $itemtype->id, |
4037 |
"Itemtype set correctly for item" ); |
4037 |
"Itemtype set correctly for item" ); |
4038 |
|
4038 |
|
4039 |
my $now = dt_from_string; |
4039 |
my $now = dt_from_string(); |
4040 |
my $dt_from = $now->clone; |
4040 |
my $dt_from = $now->clone; |
4041 |
my $dt_to = $now->clone->add( days => 7 ); |
4041 |
my $dt_to = $now->clone->add( days => 7 ); |
4042 |
my $dt_to_renew = $now->clone->add( days => 13 ); |
4042 |
my $dt_to_renew = $now->clone->add( days => 13 ); |
Lines 4412-4418
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub {
Link Here
|
4412 |
)->next; |
4412 |
)->next; |
4413 |
ok( $a, "Found accountline for lost fee" ); |
4413 |
ok( $a, "Found accountline for lost fee" ); |
4414 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
4414 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
4415 |
my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string ); |
4415 |
my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string() ); |
4416 |
$a = $a->get_from_storage; |
4416 |
$a = $a->get_from_storage; |
4417 |
is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); |
4417 |
is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); |
4418 |
$a->delete; |
4418 |
$a->delete; |
Lines 4447-4453
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub {
Link Here
|
4447 |
)->next; |
4447 |
)->next; |
4448 |
ok( $a, "Found accountline for lost fee" ); |
4448 |
ok( $a, "Found accountline for lost fee" ); |
4449 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
4449 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
4450 |
my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string ); |
4450 |
my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string() ); |
4451 |
$a = $a->get_from_storage; |
4451 |
$a = $a->get_from_storage; |
4452 |
is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); |
4452 |
is( $a->amountoutstanding + 0, 0, "Lost fee was refunded" ); |
4453 |
$a->delete; |
4453 |
$a->delete; |
Lines 4482-4488
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub {
Link Here
|
4482 |
)->next; |
4482 |
)->next; |
4483 |
ok( $a, "Found accountline for lost fee" ); |
4483 |
ok( $a, "Found accountline for lost fee" ); |
4484 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
4484 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
4485 |
my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string ); |
4485 |
my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string() ); |
4486 |
$a = $a->get_from_storage; |
4486 |
$a = $a->get_from_storage; |
4487 |
is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); |
4487 |
is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); |
4488 |
$a->delete; |
4488 |
$a->delete; |
Lines 4518-4524
subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub {
Link Here
|
4518 |
$a = $a->next; |
4518 |
$a = $a->next; |
4519 |
ok( $a, "Found accountline for lost fee" ); |
4519 |
ok( $a, "Found accountline for lost fee" ); |
4520 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
4520 |
is( $a->amountoutstanding + 0, 42, "Lost fee charged correctly" ); |
4521 |
my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string ); |
4521 |
my ( $doreturn, $messages ) = AddReturn( $item->barcode, $library->branchcode, undef, dt_from_string() ); |
4522 |
$a = $a->get_from_storage; |
4522 |
$a = $a->get_from_storage; |
4523 |
is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); |
4523 |
is( $a->amountoutstanding + 0, 42, "Lost fee was not refunded" ); |
4524 |
$a->delete; |
4524 |
$a->delete; |
Lines 4897-4904
subtest "updateWrongTransfer tests" => sub {
Link Here
|
4897 |
itemnumber => $item->itemnumber, |
4897 |
itemnumber => $item->itemnumber, |
4898 |
frombranch => $library2->branchcode, |
4898 |
frombranch => $library2->branchcode, |
4899 |
tobranch => $library1->branchcode, |
4899 |
tobranch => $library1->branchcode, |
4900 |
daterequested => dt_from_string, |
4900 |
daterequested => dt_from_string(), |
4901 |
datesent => dt_from_string, |
4901 |
datesent => dt_from_string(), |
4902 |
datecancelled => undef, |
4902 |
datecancelled => undef, |
4903 |
datearrived => undef, |
4903 |
datearrived => undef, |
4904 |
reason => 'Manual' |
4904 |
reason => 'Manual' |