Lines 20-26
Link Here
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
use utf8; |
21 |
use utf8; |
22 |
|
22 |
|
23 |
use Test::More tests => 31; |
23 |
use Test::More tests => 32; |
24 |
use Test::Exception; |
24 |
use Test::Exception; |
25 |
use Test::MockModule; |
25 |
use Test::MockModule; |
26 |
|
26 |
|
Lines 2362-2364
subtest 'location_update_trigger() tests' => sub {
Link Here
|
2362 |
|
2362 |
|
2363 |
$schema->storage->txn_rollback; |
2363 |
$schema->storage->txn_rollback; |
2364 |
}; |
2364 |
}; |
2365 |
- |
2365 |
|
|
|
2366 |
subtest 'bookings' => sub { |
2367 |
plan tests => 4; |
2368 |
|
2369 |
$schema->storage->txn_begin; |
2370 |
|
2371 |
my $biblio = $builder->build_sample_biblio(); |
2372 |
my $item = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, bookable => 1 } ); |
2373 |
is( ref($item->bookings()), 'Koha::Bookings', "Koha::Item->bookings() returns a Koha::Bookings object"); |
2374 |
is( $item->bookings->count, 0, "Nothing returned if there are no bookings" ); |
2375 |
|
2376 |
my $start_1 = dt_from_string()->subtract( days => 7 ); |
2377 |
my $end_1 = dt_from_string()->subtract( days => 1 ); |
2378 |
my $start_2 = dt_from_string(); |
2379 |
my $end_2 = dt_from_string()->add( days => 7 ); |
2380 |
my $start_3 = dt_from_string()->add( days => 8 ); |
2381 |
my $end_3 = dt_from_string()->add( days => 16 ); |
2382 |
|
2383 |
my $booking1 = $builder->build_object( |
2384 |
{ |
2385 |
class => 'Koha::Bookings', |
2386 |
value => { item_id => $item->itemnumber, start_date => $start_1, end_date => $end_1 } |
2387 |
} |
2388 |
); |
2389 |
my $booking2 = $builder->build_object( |
2390 |
{ |
2391 |
class => 'Koha::Bookings', |
2392 |
value => { item_id => $item->itemnumber, start_date => $start_2, end_date => $end_2 } |
2393 |
} |
2394 |
); |
2395 |
my $booking3 = $builder->build_object( |
2396 |
{ |
2397 |
class => 'Koha::Bookings', |
2398 |
value => { item_id => $item->itemnumber, start_date => $start_3, end_date => $end_3 } |
2399 |
} |
2400 |
); |
2401 |
|
2402 |
is( $item->bookings()->count, 3, "Three bookings found" ); |
2403 |
my $dtf = Koha::Database->new->schema->storage->datetime_parser; |
2404 |
is( |
2405 |
$item->bookings( { start_date => { '<=' => $dtf->format_datetime( dt_from_string() ) } } )->count, 2, |
2406 |
"Two bookings starts on or before today" |
2407 |
); |
2408 |
|
2409 |
$schema->storage->txn_rollback; |
2410 |
}; |