Lines 23-29
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; |
|
|
27 |
|
26 |
|
28 |
use t::lib::TestBuilder; |
27 |
use t::lib::TestBuilder; |
29 |
use t::lib::Mocks qw( mock_preference ); |
28 |
use t::lib::Mocks qw( mock_preference ); |
Lines 40-46
subtest 'Tests for CanBookBeIssued related to dateexpiry' => sub {
Link Here
|
40 |
can_book_be_issued(); |
39 |
can_book_be_issued(); |
41 |
}; |
40 |
}; |
42 |
subtest 'Tests for CalcDateDue related to dateexpiry' => sub { |
41 |
subtest 'Tests for CalcDateDue related to dateexpiry' => sub { |
43 |
plan tests => 5; |
42 |
plan tests => 4; |
44 |
calc_date_due(); |
43 |
calc_date_due(); |
45 |
}; |
44 |
}; |
46 |
|
45 |
|
Lines 83-89
sub can_book_be_issued {
Link Here
|
83 |
|
82 |
|
84 |
sub calc_date_due { |
83 |
sub calc_date_due { |
85 |
t::lib::Mocks::mock_preference( 'ReturnBeforeExpiry', 1 ); |
84 |
t::lib::Mocks::mock_preference( 'ReturnBeforeExpiry', 1 ); |
86 |
t::lib::Mocks::mock_preference( 'useDaysMode', 'Days' ); |
|
|
87 |
|
85 |
|
88 |
# this triggers the compare between expiry and due date |
86 |
# this triggers the compare between expiry and due date |
89 |
|
87 |
|
Lines 118-141
sub calc_date_due {
Link Here
|
118 |
$d = C4::Circulation::CalcDateDue( $today, $item->{itype}, $branch->{branchcode}, $patron ); |
116 |
$d = C4::Circulation::CalcDateDue( $today, $item->{itype}, $branch->{branchcode}, $patron ); |
119 |
my $t2 = time; |
117 |
my $t2 = time; |
120 |
is( ref $d eq "DateTime" && $t2 - $t1 < 1, 1, "CalcDateDue with expiry in year 9876 in " . sprintf( "%6.4f", $t2 - $t1 ) . " seconds." ); |
118 |
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 |
is ( DateTime->compare( $d, $d2) == 0, 1, "no problem with closed days"); |
139 |
} |
119 |
} |
140 |
|
120 |
|
141 |
$schema->storage->txn_rollback; |
121 |
$schema->storage->txn_rollback; |
142 |
- |
|
|