View | Details | Raw Unified | Return to bug 13517
Collapse All | Expand All

(-)a/t/db_dependent/Hold.t (-3 / +19 lines)
Lines 19-26 use Modern::Perl; Link Here
19
19
20
use C4::Context;
20
use C4::Context;
21
use Koha::Database;
21
use Koha::Database;
22
use Koha::Borrowers;
22
23
23
use Test::More tests => 8;
24
use Test::More tests => 16;
24
25
25
use_ok('Koha::Hold');
26
use_ok('Koha::Hold');
26
27
Lines 30-42 $schema->storage->txn_begin(); Link Here
30
my $dbh = C4::Context->dbh;
31
my $dbh = C4::Context->dbh;
31
$dbh->{RaiseError} = 1;
32
$dbh->{RaiseError} = 1;
32
33
33
my $hold = Koha::Hold->new({ found => 'W', waitingdate => '2000-01-01'});
34
my $borrower = Koha::Borrowers->search()->next();
35
my $hold = Koha::Hold->new(
36
    {
37
        found          => 'W',
38
        waitingdate    => '2000-01-01',
39
        borrowernumber => $borrower->borrowernumber(),
40
    }
41
);
42
my $hold_borrower = $hold->borrower();
43
ok( $hold_borrower, 'Got hold borrower' );
44
is( $hold_borrower->borrowernumber(), $borrower->borrowernumber(), 'Hold borrower matches correct borrower' );
34
45
35
C4::Context->set_preference( 'ReservesMaxPickUpDelay', '' );
46
C4::Context->set_preference( 'ReservesMaxPickUpDelay', '' );
36
my $dt = $hold->waiting_expires_on();
47
my $dt = $hold->waiting_expires_on();
37
is( $dt, undef, "Koha::Hold->waiting_expires_on returns undef if ReservesMaxPickUpDelay is not set");
48
is( $dt, undef, "Koha::Hold->waiting_expires_on returns undef if ReservesMaxPickUpDelay is not set");
38
49
39
is( $hold->is_waiting, 1, 'The hold is waiting' );
50
is( $hold->is_waiting, 1, 'The hold is waiting' );
51
is( $hold->is_found, 1, 'The hold is found');
52
isnt( $hold->is_in_transit,  'The hold is not in transit' );
40
53
41
C4::Context->set_preference( 'ReservesMaxPickUpDelay', '5' );
54
C4::Context->set_preference( 'ReservesMaxPickUpDelay', '5' );
42
$dt = $hold->waiting_expires_on();
55
$dt = $hold->waiting_expires_on();
Lines 46-56 $hold->found('T'); Link Here
46
$dt = $hold->waiting_expires_on();
59
$dt = $hold->waiting_expires_on();
47
is( $dt, undef, "Koha::Hold->waiting_expires_on returns undef if found is not 'W' ( Set to 'T' )");
60
is( $dt, undef, "Koha::Hold->waiting_expires_on returns undef if found is not 'W' ( Set to 'T' )");
48
isnt( $hold->is_waiting, 1, 'The hold is not waiting (T)' );
61
isnt( $hold->is_waiting, 1, 'The hold is not waiting (T)' );
62
is( $hold->is_found, 1, 'The hold is found');
63
is( $hold->is_in_transit, 1, 'The hold is in transit' );
49
64
50
$hold->found(q{});
65
$hold->found(q{});
51
$dt = $hold->waiting_expires_on();
66
$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 )");
67
is( $dt, undef, "Koha::Hold->waiting_expires_on returns undef if found is not 'W' ( Set to empty string )");
53
isnt( $hold->is_waiting, 1, 'The hold is not waiting (W)' );
68
isnt( $hold->is_waiting, 1, 'The hold is not waiting (W)' );
69
is( $hold->is_found, 0, 'The hold is not found' );
70
isnt( $hold->is_in_transit, 'The hold is not in transit' );
54
71
55
$schema->storage->txn_rollback();
72
$schema->storage->txn_rollback();
56
73
57
- 

Return to bug 13517