Lines 25-30
use Koha::Libraries;
Link Here
|
25 |
use Koha::Patrons; |
25 |
use Koha::Patrons; |
26 |
use Koha::Item; |
26 |
use Koha::Item; |
27 |
use Koha::DateUtils; |
27 |
use Koha::DateUtils; |
|
|
28 |
use t::lib::TestBuilder; |
28 |
|
29 |
|
29 |
use Test::More tests => 31; |
30 |
use Test::More tests => 31; |
30 |
|
31 |
|
Lines 33-43
use_ok('Koha::Hold');
Link Here
|
33 |
my $schema = Koha::Database->new()->schema(); |
34 |
my $schema = Koha::Database->new()->schema(); |
34 |
$schema->storage->txn_begin(); |
35 |
$schema->storage->txn_begin(); |
35 |
|
36 |
|
36 |
my $dbh = C4::Context->dbh; |
37 |
# add two branches and a borrower |
37 |
$dbh->{RaiseError} = 1; |
38 |
my $builder = t::lib::TestBuilder->new; |
38 |
|
39 |
my @branches; |
39 |
my @branches = Koha::Libraries->search(); |
40 |
foreach( 1..2 ) { |
40 |
my $borrower = Koha::Patrons->search()->next(); |
41 |
push @branches, $builder->build({ source => 'Branch' }); |
|
|
42 |
} |
43 |
my $borrower = $builder->build({ source => 'Borrower' }); |
41 |
|
44 |
|
42 |
my $biblio = MARC::Record->new(); |
45 |
my $biblio = MARC::Record->new(); |
43 |
my $title = 'Silence in the library'; |
46 |
my $title = 'Silence in the library'; |
Lines 51-58
my $item = Koha::Item->new(
Link Here
|
51 |
{ |
54 |
{ |
52 |
biblionumber => $biblionumber, |
55 |
biblionumber => $biblionumber, |
53 |
biblioitemnumber => $biblioitemnumber, |
56 |
biblioitemnumber => $biblioitemnumber, |
54 |
holdingbranch => $branches[0]->branchcode(), |
57 |
holdingbranch => $branches[0]->{branchcode}, |
55 |
homebranch => $branches[0]->branchcode(), |
58 |
homebranch => $branches[0]->{branchcode}, |
56 |
} |
59 |
} |
57 |
); |
60 |
); |
58 |
$item->store(); |
61 |
$item->store(); |
Lines 62-69
my $hold = Koha::Hold->new(
Link Here
|
62 |
biblionumber => $biblionumber, |
65 |
biblionumber => $biblionumber, |
63 |
itemnumber => $item->id(), |
66 |
itemnumber => $item->id(), |
64 |
waitingdate => '2000-01-01', |
67 |
waitingdate => '2000-01-01', |
65 |
borrowernumber => $borrower->borrowernumber(), |
68 |
borrowernumber => $borrower->{borrowernumber}, |
66 |
branchcode => $branches[1]->branchcode(), |
69 |
branchcode => $branches[1]->{branchcode}, |
67 |
suspend => 0, |
70 |
suspend => 0, |
68 |
} |
71 |
} |
69 |
); |
72 |
); |
Lines 90-96
$item = $hold->item();
Link Here
|
90 |
|
93 |
|
91 |
my $hold_borrower = $hold->borrower(); |
94 |
my $hold_borrower = $hold->borrower(); |
92 |
ok( $hold_borrower, 'Got hold borrower' ); |
95 |
ok( $hold_borrower, 'Got hold borrower' ); |
93 |
is( $hold_borrower->borrowernumber(), $borrower->borrowernumber(), 'Hold borrower matches correct borrower' ); |
96 |
is( $hold_borrower->borrowernumber(), $borrower->{borrowernumber}, 'Hold borrower matches correct borrower' ); |
94 |
|
97 |
|
95 |
t::lib::Mocks::mock_preference( 'ReservesMaxPickUpDelay', '' ); |
98 |
t::lib::Mocks::mock_preference( 'ReservesMaxPickUpDelay', '' ); |
96 |
$dt = $hold->waiting_expires_on(); |
99 |
$dt = $hold->waiting_expires_on(); |
Lines 134-140
$hold->found('T');
Link Here
|
134 |
ok( !$hold->is_at_destination(), "In transit hold cannot be at destination" ); |
137 |
ok( !$hold->is_at_destination(), "In transit hold cannot be at destination" ); |
135 |
$hold->found('W'); |
138 |
$hold->found('W'); |
136 |
ok( !$hold->is_at_destination(), "Waiting hold where hold branchcode is not the same as the item's holdingbranch is not at destination" ); |
139 |
ok( !$hold->is_at_destination(), "Waiting hold where hold branchcode is not the same as the item's holdingbranch is not at destination" ); |
137 |
$item->holdingbranch( $branches[1]->branchcode() ); |
140 |
$item->holdingbranch( $branches[1]->{branchcode} ); |
138 |
ok( $hold->is_at_destination(), "Waiting hold where hold branchcode is the same as the item's holdingbranch is at destination" ); |
141 |
ok( $hold->is_at_destination(), "Waiting hold where hold branchcode is the same as the item's holdingbranch is at destination" ); |
139 |
|
142 |
|
140 |
$schema->storage->txn_rollback(); |
143 |
$schema->storage->txn_rollback(); |
141 |
- |
|
|