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 2502-2504 subtest 'filter_by_in_transit' => sub { Link Here
2502
    $schema->storage->txn_rollback;
2503
    $schema->storage->txn_rollback;
2503
2504
2504
};
2505
};
2505
- 
2506
2507
subtest 'filter_by_has_holds' => sub {
2508
    plan tests => 3;
2509
2510
    $schema->storage->txn_begin;
2511
2512
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
2513
    t::lib::Mocks::mock_userenv( { branchcode => $patron->branchcode } );
2514
2515
    my $library_1 = $builder->build( { source => 'Branch' } );
2516
    my $library_2 = $builder->build( { source => 'Branch' } );
2517
2518
    my $biblio = $builder->build_sample_biblio();
2519
    my $item_1 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, } );
2520
    my $item_2 = $builder->build_sample_item( { biblionumber => $biblio->biblionumber, } );
2521
2522
    is( $biblio->items->filter_by_has_holds->count, 0, "Filtered to 0 holds" );
2523
2524
    my $hold_1 = $builder->build(
2525
        {
2526
            source => 'Reserve',
2527
            value  => {
2528
                itemnumber => $item_1->itemnumber, reservedate => dt_from_string,
2529
            }
2530
        }
2531
    );
2532
2533
    is( $biblio->items->filter_by_has_holds->count, 1, "Filtered to 1 hold" );
2534
2535
    my $hold_2 = $builder->build(
2536
        {
2537
            source => 'Reserve',
2538
            value  => {
2539
                itemnumber => $item_2->itemnumber, reservedate => dt_from_string,
2540
            }
2541
        }
2542
    );
2543
2544
    is( $biblio->items->filter_by_has_holds->count, 2, "Filtered to 2 holds" );
2545
2546
    $schema->storage->txn_rollback;
2547
2548
};

Return to bug 37334