|
Lines 19-25
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 21; |
22 |
use Test::More tests => 22; |
| 23 |
|
23 |
|
| 24 |
use Test::MockModule; |
24 |
use Test::MockModule; |
| 25 |
use Test::Exception; |
25 |
use Test::Exception; |
|
Lines 2455-2457
subtest 'filter_by_checked_out' => sub {
Link Here
|
| 2455 |
$schema->storage->txn_rollback; |
2455 |
$schema->storage->txn_rollback; |
| 2456 |
|
2456 |
|
| 2457 |
}; |
2457 |
}; |
| 2458 |
- |
2458 |
|
|
|
2459 |
subtest 'filter_by_in_transit' => sub { |
| 2460 |
plan tests => 3; |
| 2461 |
|
| 2462 |
$schema->storage->txn_begin; |
| 2463 |
|
| 2464 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 2465 |
t::lib::Mocks::mock_userenv( { branchcode => $patron->branchcode } ); |
| 2466 |
|
| 2467 |
my $library_1 = $builder->build( { source => 'Branch' } ); |
| 2468 |
my $library_2 = $builder->build( { source => 'Branch' } ); |
| 2469 |
|
| 2470 |
my $biblio = $builder->build_sample_biblio(); |
| 2471 |
my $item_1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, } ); |
| 2472 |
my $item_2 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, } ); |
| 2473 |
|
| 2474 |
is( $biblio->items->filter_by_in_transit->count, 0, "Filtered 0 in transit items" ); |
| 2475 |
|
| 2476 |
my $transfer_1 = $builder->build_object( |
| 2477 |
{ |
| 2478 |
class => 'Koha::Item::Transfers', |
| 2479 |
value => { |
| 2480 |
itemnumber => $item_1->itemnumber, |
| 2481 |
frombranch => $library_1->{branchcode}, |
| 2482 |
tobranch => $library_2->{branchcode}, |
| 2483 |
} |
| 2484 |
} |
| 2485 |
); |
| 2486 |
|
| 2487 |
is( $biblio->items->filter_by_in_transit->count, 1, "Filtered 1 in transit items" ); |
| 2488 |
|
| 2489 |
my $transfer_2 = $builder->build_object( |
| 2490 |
{ |
| 2491 |
class => 'Koha::Item::Transfers', |
| 2492 |
value => { |
| 2493 |
itemnumber => $item_2->itemnumber, |
| 2494 |
frombranch => $library_2->{branchcode}, |
| 2495 |
tobranch => $library_1->{branchcode}, |
| 2496 |
} |
| 2497 |
} |
| 2498 |
); |
| 2499 |
|
| 2500 |
is( $biblio->items->filter_by_in_transit->count, 2, "Filtered 2 in transit items" ); |
| 2501 |
|
| 2502 |
$schema->storage->txn_rollback; |
| 2503 |
|
| 2504 |
}; |