Lines 17-45
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::MockModule; |
20 |
use C4::Context; |
|
|
21 |
use Koha::Database; |
22 |
|
21 |
use Test::More tests => 5; |
23 |
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 |
|
24 |
|
34 |
use_ok('Koha::Hold'); |
25 |
use_ok('Koha::Hold'); |
35 |
|
26 |
|
|
|
27 |
my $schema = Koha::Database->new()->schema(); |
28 |
$schema->storage->txn_begin(); |
29 |
|
30 |
my $dbh = C4::Context->dbh; |
31 |
$dbh->{RaiseError} = 1; |
32 |
|
36 |
my $hold = Koha::Hold->new({ found => 'W', waitingdate => '2000-01-01'}); |
33 |
my $hold = Koha::Hold->new({ found => 'W', waitingdate => '2000-01-01'}); |
37 |
|
34 |
|
38 |
t::lib::Mocks::mock_preference('ReservesMaxPickUpDelay', undef); |
35 |
C4::Context->set_preference( 'ReservesMaxPickUpDelay', '' ); |
39 |
my $dt = $hold->waiting_expires_on(); |
36 |
my $dt = $hold->waiting_expires_on(); |
40 |
is( $dt, undef, "Koha::Hold->waiting_expires_on returns undef if ReservesMaxPickUpDelay is not set"); |
37 |
is( $dt, undef, "Koha::Hold->waiting_expires_on returns undef if ReservesMaxPickUpDelay is not set"); |
41 |
|
38 |
|
42 |
t::lib::Mocks::mock_preference('ReservesMaxPickUpDelay', 5); |
39 |
C4::Context->set_preference( 'ReservesMaxPickUpDelay', '5' ); |
43 |
$dt = $hold->waiting_expires_on(); |
40 |
$dt = $hold->waiting_expires_on(); |
44 |
is( $dt->ymd, "2000-01-06", "Koha::Hold->waiting_expires_on returns DateTime of waitingdate + ReservesMaxPickUpDelay if set"); |
41 |
is( $dt->ymd, "2000-01-06", "Koha::Hold->waiting_expires_on returns DateTime of waitingdate + ReservesMaxPickUpDelay if set"); |
45 |
|
42 |
|
Lines 51-54
$hold->found(q{});
Link Here
|
51 |
$dt = $hold->waiting_expires_on(); |
48 |
$dt = $hold->waiting_expires_on(); |
52 |
is( $dt, undef, "Koha::Hold->waiting_expires_on returns undef if found is not 'W' ( Set to empty string )"); |
49 |
is( $dt, undef, "Koha::Hold->waiting_expires_on returns undef if found is not 'W' ( Set to empty string )"); |
53 |
|
50 |
|
|
|
51 |
$schema->storage->txn_rollback(); |
52 |
|
54 |
1; |
53 |
1; |
55 |
- |
|
|