Lines 23-28
use Test::More tests => 2;
Link Here
|
23 |
use C4::Members; |
23 |
use C4::Members; |
24 |
use Koha::DateUtils; |
24 |
use Koha::DateUtils; |
25 |
use Koha::Database; |
25 |
use Koha::Database; |
|
|
26 |
use C4::Calendar; |
26 |
|
27 |
|
27 |
use t::lib::TestBuilder; |
28 |
use t::lib::TestBuilder; |
28 |
use t::lib::Mocks qw( mock_preference ); |
29 |
use t::lib::Mocks qw( mock_preference ); |
Lines 39-45
subtest 'Tests for CanBookBeIssued related to dateexpiry' => sub {
Link Here
|
39 |
can_book_be_issued(); |
40 |
can_book_be_issued(); |
40 |
}; |
41 |
}; |
41 |
subtest 'Tests for CalcDateDue related to dateexpiry' => sub { |
42 |
subtest 'Tests for CalcDateDue related to dateexpiry' => sub { |
42 |
plan tests => 4; |
43 |
plan tests => 5; |
43 |
calc_date_due(); |
44 |
calc_date_due(); |
44 |
}; |
45 |
}; |
45 |
|
46 |
|
Lines 82-87
sub can_book_be_issued {
Link Here
|
82 |
|
83 |
|
83 |
sub calc_date_due { |
84 |
sub calc_date_due { |
84 |
t::lib::Mocks::mock_preference( 'ReturnBeforeExpiry', 1 ); |
85 |
t::lib::Mocks::mock_preference( 'ReturnBeforeExpiry', 1 ); |
|
|
86 |
t::lib::Mocks::mock_preference( 'useDaysMode', 'Days' ); |
85 |
|
87 |
|
86 |
# this triggers the compare between expiry and due date |
88 |
# this triggers the compare between expiry and due date |
87 |
|
89 |
|
Lines 116-121
sub calc_date_due {
Link Here
|
116 |
$d = C4::Circulation::CalcDateDue( $today, $item->{itype}, $branch->{branchcode}, $patron ); |
118 |
$d = C4::Circulation::CalcDateDue( $today, $item->{itype}, $branch->{branchcode}, $patron ); |
117 |
my $t2 = time; |
119 |
my $t2 = time; |
118 |
is( ref $d eq "DateTime" && $t2 - $t1 < 1, 1, "CalcDateDue with expiry in year 9876 in " . sprintf( "%6.4f", $t2 - $t1 ) . " seconds." ); |
120 |
is( ref $d eq "DateTime" && $t2 - $t1 < 1, 1, "CalcDateDue with expiry in year 9876 in " . sprintf( "%6.4f", $t2 - $t1 ) . " seconds." ); |
|
|
121 |
|
122 |
# fifth test takes account of closed days |
123 |
$d = C4::Circulation::CalcDateDue( $today, $item->{itype}, $branch->{branchcode}, $patron ); |
124 |
t::lib::Mocks::mock_preference( 'useDaysMode', 'Datedue' ); |
125 |
my $calendar = C4::Calendar->new(branchcode => $branch->{branchcode}); |
126 |
$calendar->insert_single_holiday( |
127 |
day => $d->day(), |
128 |
month => $d->month(), |
129 |
year => $d->year(), |
130 |
title =>'holidayTest', |
131 |
description => 'holidayDesc' |
132 |
); |
133 |
$calendar->delete_holiday(weekday => $d->day_of_week() - 1, day => $d->day()-1, month =>$d->month(), year=>$d->year() ); |
134 |
$d2 = C4::Circulation::CalcDateDue( $today, $item->{itype}, $branch->{branchcode}, $patron ); |
135 |
$d2->add(days => 1); |
136 |
$d->truncate( to => 'day' ); |
137 |
$d2->truncate( to => 'day' ); |
138 |
warn Data::Dumper::Dumper($d->datetime()); |
139 |
warn Data::Dumper::Dumper($d2->datetime()); |
140 |
is ( DateTime->compare( $d, $d2) == 0, 1, "no problem with closed days"); |
119 |
} |
141 |
} |
120 |
|
142 |
|
121 |
$schema->storage->txn_rollback; |
143 |
$schema->storage->txn_rollback; |
122 |
- |
|
|