|
Lines 27-33
use Koha::Item;
Link Here
|
| 27 |
use Koha::DateUtils; |
27 |
use Koha::DateUtils; |
| 28 |
use t::lib::TestBuilder; |
28 |
use t::lib::TestBuilder; |
| 29 |
|
29 |
|
| 30 |
use Test::More tests => 32; |
30 |
use Test::More tests => 28; |
| 31 |
use Test::Warn; |
31 |
use Test::Warn; |
| 32 |
|
32 |
|
| 33 |
use_ok('Koha::Hold'); |
33 |
use_ok('Koha::Hold'); |
|
Lines 97-125
my $hold_borrower = $hold->borrower();
Link Here
|
| 97 |
ok( $hold_borrower, 'Got hold borrower' ); |
97 |
ok( $hold_borrower, 'Got hold borrower' ); |
| 98 |
is( $hold_borrower->borrowernumber(), $borrower->{borrowernumber}, 'Hold borrower matches correct borrower' ); |
98 |
is( $hold_borrower->borrowernumber(), $borrower->{borrowernumber}, 'Hold borrower matches correct borrower' ); |
| 99 |
|
99 |
|
| 100 |
t::lib::Mocks::mock_preference( 'ReservesMaxPickUpDelay', '' ); |
|
|
| 101 |
$dt = $hold->waiting_expires_on(); |
| 102 |
is( $dt, undef, "Koha::Hold->waiting_expires_on returns undef if ReservesMaxPickUpDelay is not set" ); |
| 103 |
|
| 104 |
is( $hold->is_waiting, 1, 'The hold is waiting' ); |
100 |
is( $hold->is_waiting, 1, 'The hold is waiting' ); |
| 105 |
is( $hold->is_found, 1, 'The hold is found'); |
101 |
is( $hold->is_found, 1, 'The hold is found'); |
| 106 |
ok( !$hold->is_in_transit, 'The hold is not in transit' ); |
102 |
ok( !$hold->is_in_transit, 'The hold is not in transit' ); |
| 107 |
|
103 |
|
| 108 |
t::lib::Mocks::mock_preference( 'ReservesMaxPickUpDelay', '5' ); |
104 |
t::lib::Mocks::mock_preference( 'ReservesMaxPickUpDelay', '5' ); |
| 109 |
$dt = $hold->waiting_expires_on(); |
|
|
| 110 |
is( $dt->ymd, "2000-01-06", |
| 111 |
"Koha::Hold->waiting_expires_on returns DateTime of waitingdate + ReservesMaxPickUpDelay if set" ); |
| 112 |
|
| 113 |
$hold->found('T'); |
105 |
$hold->found('T'); |
| 114 |
$dt = $hold->waiting_expires_on(); |
|
|
| 115 |
is( $dt, undef, "Koha::Hold->waiting_expires_on returns undef if found is not 'W' ( Set to 'T' )" ); |
| 116 |
isnt( $hold->is_waiting, 1, 'The hold is not waiting (T)' ); |
106 |
isnt( $hold->is_waiting, 1, 'The hold is not waiting (T)' ); |
| 117 |
is( $hold->is_found, 1, 'The hold is found'); |
107 |
is( $hold->is_found, 1, 'The hold is found'); |
| 118 |
is( $hold->is_in_transit, 1, 'The hold is in transit' ); |
108 |
is( $hold->is_in_transit, 1, 'The hold is in transit' ); |
| 119 |
|
109 |
|
| 120 |
$hold->found(q{}); |
110 |
$hold->found(q{}); |
| 121 |
$dt = $hold->waiting_expires_on(); |
|
|
| 122 |
is( $dt, undef, "Koha::Hold->waiting_expires_on returns undef if found is not 'W' ( Set to empty string )" ); |
| 123 |
isnt( $hold->is_waiting, 1, 'The hold is not waiting (W)' ); |
111 |
isnt( $hold->is_waiting, 1, 'The hold is not waiting (W)' ); |
| 124 |
is( $hold->is_found, 0, 'The hold is not found' ); |
112 |
is( $hold->is_found, 0, 'The hold is not found' ); |
| 125 |
ok( !$hold->is_in_transit, 'The hold is not in transit' ); |
113 |
ok( !$hold->is_in_transit, 'The hold is not in transit' ); |
| 126 |
- |
|
|