View | Details | Raw Unified | Return to bug 37334
Collapse All | Expand All

(-)a/t/db_dependent/Koha/Items.t (-2 / +45 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 22;
22
use Test::More tests => 23;
23
23
24
use Test::MockModule;
24
use Test::MockModule;
25
use Test::Exception;
25
use Test::Exception;
Lines 34-39 use Koha::Items; Link Here
34
use Koha::Database;
34
use Koha::Database;
35
use Koha::DateUtils qw( dt_from_string );
35
use Koha::DateUtils qw( dt_from_string );
36
use Koha::Statistics;
36
use Koha::Statistics;
37
use Koha::Recalls;
37
38
38
use t::lib::TestBuilder;
39
use t::lib::TestBuilder;
39
use t::lib::Mocks;
40
use t::lib::Mocks;
Lines 2301-2303 subtest 'filter_by_in_transit' => sub { Link Here
2301
    $schema->storage->txn_rollback;
2302
    $schema->storage->txn_rollback;
2302
2303
2303
};
2304
};
2304
- 
2305
2306
subtest 'filter_by_has_holds' => sub {
2307
    plan tests => 3;
2308
2309
    $schema->storage->txn_begin;
2310
2311
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
2312
    t::lib::Mocks::mock_userenv( { branchcode => $patron->branchcode } );
2313
2314
    my $library_1 = $builder->build( { source => 'Branch' } );
2315
    my $library_2 = $builder->build( { source => 'Branch' } );
2316
2317
    my $biblio = $builder->build_sample_biblio();
2318
    my $item_1 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber, });
2319
    my $item_2 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber, });
2320
2321
    is ( $biblio->items->filter_by_has_holds->count, 0, "Filtered to 0 holds" );
2322
2323
    my $hold_1 = $builder->build(
2324
        {
2325
            source => 'Reserve',
2326
            value  => {
2327
                itemnumber => $item_1->itemnumber, reservedate => dt_from_string,
2328
            }
2329
        }
2330
    );
2331
2332
    is ( $biblio->items->filter_by_has_holds->count, 1, "Filtered to 1 hold" );
2333
2334
    my $hold_2 = $builder->build(
2335
        {
2336
            source => 'Reserve',
2337
            value  => {
2338
                itemnumber => $item_2->itemnumber, reservedate => dt_from_string,
2339
            }
2340
        }
2341
    );
2342
2343
    is ( $biblio->items->filter_by_has_holds->count, 2, "Filtered to 2 holds" );
2344
2345
    $schema->storage->txn_rollback;
2346
2347
};

Return to bug 37334