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

(-)a/t/db_dependent/Koha/Items.t (-2 / +45 lines)
Lines 20-26 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::NoWarnings;
22
use Test::NoWarnings;
23
use Test::More tests => 22;
23
use Test::More tests => 23;
24
24
25
use Test::MockModule;
25
use Test::MockModule;
26
use Test::Exception;
26
use Test::Exception;
Lines 35-40 use Koha::Items; Link Here
35
use Koha::Database;
35
use Koha::Database;
36
use Koha::DateUtils qw( dt_from_string );
36
use Koha::DateUtils qw( dt_from_string );
37
use Koha::Statistics;
37
use Koha::Statistics;
38
use Koha::Recalls;
38
39
39
use t::lib::TestBuilder;
40
use t::lib::TestBuilder;
40
use t::lib::Mocks;
41
use t::lib::Mocks;
Lines 2503-2505 subtest 'filter_by_in_transit' => sub { Link Here
2503
    $schema->storage->txn_rollback;
2504
    $schema->storage->txn_rollback;
2504
2505
2505
};
2506
};
2506
- 
2507
2508
subtest 'filter_by_has_holds' => sub {
2509
    plan tests => 3;
2510
2511
    $schema->storage->txn_begin;
2512
2513
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
2514
    t::lib::Mocks::mock_userenv( { branchcode => $patron->branchcode } );
2515
2516
    my $library_1 = $builder->build( { source => 'Branch' } );
2517
    my $library_2 = $builder->build( { source => 'Branch' } );
2518
2519
    my $biblio = $builder->build_sample_biblio();
2520
    my $item_1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, } );
2521
    my $item_2 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, } );
2522
2523
    is( $biblio->items->filter_by_has_holds->count, 0, "Filtered to 0 holds" );
2524
2525
    my $hold_1 = $builder->build(
2526
        {
2527
            source => 'Reserve',
2528
            value  => {
2529
                itemnumber => $item_1->itemnumber, reservedate => dt_from_string,
2530
            }
2531
        }
2532
    );
2533
2534
    is( $biblio->items->filter_by_has_holds->count, 1, "Filtered to 1 hold" );
2535
2536
    my $hold_2 = $builder->build(
2537
        {
2538
            source => 'Reserve',
2539
            value  => {
2540
                itemnumber => $item_2->itemnumber, reservedate => dt_from_string,
2541
            }
2542
        }
2543
    );
2544
2545
    is( $biblio->items->filter_by_has_holds->count, 2, "Filtered to 2 holds" );
2546
2547
    $schema->storage->txn_rollback;
2548
2549
};

Return to bug 37334