Lines 19-30
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 6; |
22 |
use Test::More tests => 7; |
23 |
|
23 |
|
24 |
use t::lib::TestBuilder; |
24 |
use t::lib::TestBuilder; |
25 |
use t::lib::Mocks; |
25 |
use t::lib::Mocks; |
26 |
|
26 |
|
27 |
use Koha::Database; |
27 |
use Koha::Database; |
|
|
28 |
use Koha::DateUtils qw(dt_from_string); |
28 |
|
29 |
|
29 |
my $schema = Koha::Database->schema; |
30 |
my $schema = Koha::Database->schema; |
30 |
my $builder = t::lib::TestBuilder->new; |
31 |
my $builder = t::lib::TestBuilder->new; |
Lines 250-252
subtest 'duplicate_to | add_item' => sub {
Link Here
|
250 |
|
251 |
|
251 |
$schema->storage->txn_rollback; |
252 |
$schema->storage->txn_rollback; |
252 |
}; |
253 |
}; |
253 |
- |
254 |
|
|
|
255 |
subtest 'current_holds() tests' => sub { |
256 |
|
257 |
plan tests => 3; |
258 |
|
259 |
$schema->storage->txn_begin; |
260 |
|
261 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
262 |
my $biblio = $builder->build_sample_biblio(); |
263 |
my $item_1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); |
264 |
my $item_2 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); |
265 |
my $item_3 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); |
266 |
|
267 |
C4::Reserves::AddReserve( |
268 |
$patron->branchcode, $patron->borrowernumber, |
269 |
$biblio->biblionumber, undef, |
270 |
undef, dt_from_string->add( days => -2 ), |
271 |
undef, undef, |
272 |
undef, $item_1->itemnumber |
273 |
); |
274 |
C4::Reserves::AddReserve( |
275 |
$patron->branchcode, $patron->borrowernumber, |
276 |
$biblio->biblionumber, undef, |
277 |
undef, dt_from_string->add( days => -2 ), |
278 |
undef, undef, |
279 |
undef, $item_2->itemnumber |
280 |
); |
281 |
# Add a hold in the future |
282 |
C4::Reserves::AddReserve( |
283 |
$patron->branchcode, $patron->borrowernumber, |
284 |
$biblio->biblionumber, undef, |
285 |
undef, dt_from_string->add( days => 2 ), |
286 |
undef, undef, |
287 |
undef, $item_3->itemnumber |
288 |
); |
289 |
|
290 |
# Add an order with no biblionumber |
291 |
my $order = $builder->build_object( |
292 |
{ |
293 |
class => 'Koha::Acquisition::Orders', |
294 |
value => { |
295 |
biblionumber => undef |
296 |
} |
297 |
} |
298 |
); |
299 |
|
300 |
is( $order->current_holds, undef, 'Returns undef if no linked biblio'); |
301 |
|
302 |
$order->set({ biblionumber => $biblio->biblionumber })->store->discard_changes; |
303 |
|
304 |
is( $order->current_holds, undef, 'Returns undef if no linked items'); |
305 |
|
306 |
$order->add_item( $item_2->itemnumber ); |
307 |
$order->add_item( $item_3->itemnumber ); |
308 |
|
309 |
is( $order->current_holds->count, 1, 'Only current (not future) holds are returned'); |
310 |
|
311 |
$schema->storage->txn_rollback; |
312 |
}; |