Lines 19-30
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 20; |
22 |
use Test::More tests => 21; |
23 |
|
23 |
|
24 |
use Test::MockModule; |
24 |
use Test::MockModule; |
25 |
use Test::Exception; |
25 |
use Test::Exception; |
26 |
use Time::Fake; |
26 |
use Time::Fake; |
27 |
|
27 |
|
|
|
28 |
use List::MoreUtils qw(none); |
29 |
|
28 |
use C4::Circulation qw( AddIssue LostItem AddReturn ); |
30 |
use C4::Circulation qw( AddIssue LostItem AddReturn ); |
29 |
use C4::Context; |
31 |
use C4::Context; |
30 |
use C4::Serials qw( NewIssue AddItem2Serial ); |
32 |
use C4::Serials qw( NewIssue AddItem2Serial ); |
Lines 2222-2224
subtest 'filter_by_bookable' => sub {
Link Here
|
2222 |
|
2224 |
|
2223 |
$schema->storage->txn_rollback; |
2225 |
$schema->storage->txn_rollback; |
2224 |
}; |
2226 |
}; |
2225 |
- |
2227 |
|
|
|
2228 |
subtest 'filter_by_checked_out() tests' => sub { |
2229 |
|
2230 |
plan tests => 6; |
2231 |
|
2232 |
$schema->storage->txn_begin; |
2233 |
|
2234 |
my $item_1 = $builder->build_sample_item(); |
2235 |
my $item_2 = $builder->build_sample_item(); |
2236 |
my $item_3 = $builder->build_sample_item(); |
2237 |
|
2238 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
2239 |
t::lib::Mocks::mock_userenv( { patron => $patron, branchcode => $patron->branchcode } ); |
2240 |
|
2241 |
my $items = Koha::Items->search( { 'me.itemnumber' => [ $item_1->id, $item_2->id, $item_3->id ] } ); |
2242 |
|
2243 |
is( $items->count, 3, '3 items in the resultset' ); |
2244 |
|
2245 |
my $filtered_rs = $items->filter_by_checked_out(); |
2246 |
is( $filtered_rs->count, 0, 'No checked out items in the resultset' ); |
2247 |
|
2248 |
AddIssue( $patron, $item_3->barcode ); |
2249 |
$filtered_rs = $items->filter_by_checked_out(); |
2250 |
|
2251 |
is( $filtered_rs->count, 1, '1 item in the resultset' ); |
2252 |
is( $filtered_rs->next->id, $item_3->id, 'The checked out item remains in the resultset' ); |
2253 |
|
2254 |
AddIssue( $patron, $item_1->barcode ); |
2255 |
$filtered_rs = $items->filter_by_checked_out(); |
2256 |
|
2257 |
is( $filtered_rs->count, 2, '2 item in the resultset' ); |
2258 |
ok( ( none { $_->id == $item_2->id } $filtered_rs->as_list ), 'The item not checked out is not in the resultset' ); |
2259 |
|
2260 |
$schema->storage->txn_rollback; |
2261 |
}; |