Line 0
Link Here
|
0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
# This file is part of Koha. |
4 |
# |
5 |
# Koha is free software; you can redistribute it and/or modify it |
6 |
# under the terms of the GNU General Public License as published by |
7 |
# the Free Software Foundation; either version 3 of the License, or |
8 |
# (at your option) any later version. |
9 |
# |
10 |
# Koha is distributed in the hope that it will be useful, but |
11 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
# GNU General Public License for more details. |
14 |
# |
15 |
# You should have received a copy of the GNU General Public License |
16 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
17 |
|
18 |
use Modern::Perl; |
19 |
|
20 |
use Test::MockModule; |
21 |
use Test::More tests => 5; |
22 |
use t::lib::Mocks; |
23 |
|
24 |
my $module = new Test::MockModule('C4::Context'); |
25 |
$module->mock( |
26 |
'_new_dbh', |
27 |
sub { |
28 |
my $dbh = DBI->connect( 'DBI:Mock:', '', '' ) |
29 |
|| die "Cannot create handle: $DBI::errstr\n"; |
30 |
return $dbh; |
31 |
} |
32 |
); |
33 |
|
34 |
use_ok('Koha::Hold'); |
35 |
|
36 |
my $hold = Koha::Hold->new({ found => 'W', waitingdate => '2000-01-01'}); |
37 |
|
38 |
t::lib::Mocks::mock_preference('ReservesMaxPickUpDelay', undef); |
39 |
my $dt = $hold->WaitingExpiresOn(); |
40 |
is( $dt, undef, "Koha::Hold->WaitingExpiresOn returns undef if ReservesMaxPickUpDelay is not set"); |
41 |
|
42 |
t::lib::Mocks::mock_preference('ReservesMaxPickUpDelay', 5); |
43 |
$dt = $hold->WaitingExpiresOn(); |
44 |
is( $dt->ymd, "2000-01-06", "Koha::Hold->WaitingExpiresOn returns DateTime of waitingdate + ReservesMaxPickUpDelay if set"); |
45 |
|
46 |
$hold->found('T'); |
47 |
$dt = $hold->WaitingExpiresOn(); |
48 |
is( $dt, undef, "Koha::Hold->WaitingExpiresOn returns undef if found is not 'W' ( Set to 'T' )"); |
49 |
|
50 |
$hold->found(q{}); |
51 |
$dt = $hold->WaitingExpiresOn(); |
52 |
is( $dt, undef, "Koha::Hold->WaitingExpiresOn returns undef if found is not 'W' ( Set to empty string )"); |
53 |
|
54 |
1; |