Lines 19-29
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 4; |
22 |
use Test::More tests => 5; |
23 |
|
23 |
|
24 |
use Koha::Checkout; |
|
|
25 |
use Koha::Checkouts; |
24 |
use Koha::Checkouts; |
26 |
use Koha::Database; |
25 |
use Koha::Database; |
|
|
26 |
use Koha::DateUtils qw( dt_from_string ); |
27 |
|
27 |
|
28 |
use t::lib::TestBuilder; |
28 |
use t::lib::TestBuilder; |
29 |
|
29 |
|
Lines 55-60
is( Koha::Checkouts->search->count, $nb_of_checkouts + 2, 'The 2 checkouts shoul
Link Here
|
55 |
my $retrieved_checkout_1 = Koha::Checkouts->find( $new_checkout_1->issue_id ); |
55 |
my $retrieved_checkout_1 = Koha::Checkouts->find( $new_checkout_1->issue_id ); |
56 |
is( $retrieved_checkout_1->itemnumber, $new_checkout_1->itemnumber, 'Find a checkout by id should return the correct checkout' ); |
56 |
is( $retrieved_checkout_1->itemnumber, $new_checkout_1->itemnumber, 'Find a checkout by id should return the correct checkout' ); |
57 |
|
57 |
|
|
|
58 |
subtest 'is_overdue' => sub { |
59 |
plan tests => 6; |
60 |
my $ten_days_ago = dt_from_string->add( days => -10 ); |
61 |
my $ten_days_later = dt_from_string->add( days => 10 ); |
62 |
my $yesterday = dt_from_string->add( days => -1 ); |
63 |
my $tomorrow = dt_from_string->add( days => 1 ); |
64 |
|
65 |
$retrieved_checkout_1->date_due($ten_days_ago)->store; |
66 |
is( $retrieved_checkout_1->is_overdue, |
67 |
1, 'The item should have been returned 10 days ago' ); |
68 |
|
69 |
$retrieved_checkout_1->date_due($ten_days_later)->store; |
70 |
is( $retrieved_checkout_1->is_overdue, 0, 'The item is due in 10 days' ); |
71 |
|
72 |
$retrieved_checkout_1->date_due($tomorrow)->store; |
73 |
is( $retrieved_checkout_1->is_overdue($ten_days_later), |
74 |
1, 'The item should have been returned yesterday' ); |
75 |
|
76 |
$retrieved_checkout_1->date_due($yesterday)->store; |
77 |
is( $retrieved_checkout_1->is_overdue($ten_days_ago), |
78 |
0, 'Ten days ago the item due yesterday was not late' ); |
79 |
|
80 |
$retrieved_checkout_1->date_due($tomorrow)->store; |
81 |
is( $retrieved_checkout_1->is_overdue($ten_days_later), |
82 |
1, 'In Ten days, the item due tomorrow will be late' ); |
83 |
|
84 |
$retrieved_checkout_1->date_due($yesterday)->store; |
85 |
is( $retrieved_checkout_1->is_overdue($ten_days_ago), |
86 |
0, 'In Ten days, the item due yesterday will still be late' ); |
87 |
}; |
88 |
|
58 |
$retrieved_checkout_1->delete; |
89 |
$retrieved_checkout_1->delete; |
59 |
is( Koha::Checkouts->search->count, $nb_of_checkouts + 1, 'Delete should have deleted the checkout' ); |
90 |
is( Koha::Checkouts->search->count, $nb_of_checkouts + 1, 'Delete should have deleted the checkout' ); |
60 |
|
91 |
|
61 |
- |
|
|