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

(-)a/t/db_dependent/Items.t (-2 / +48 lines)
Lines 309-315 subtest q{Test Koha::Database->schema()->resultset('Item')->itemtype()} => sub { Link Here
309
};
309
};
310
310
311
subtest 'SearchItems test' => sub {
311
subtest 'SearchItems test' => sub {
312
    plan tests => 19;
312
    plan tests => 20;
313
313
314
    $schema->storage->txn_begin;
314
    $schema->storage->txn_begin;
315
    my $dbh = C4::Context->dbh;
315
    my $dbh = C4::Context->dbh;
Lines 567-572 subtest 'SearchItems test' => sub { Link Here
567
    ($items, $total_results) = SearchItems($filter,$params);
567
    ($items, $total_results) = SearchItems($filter,$params);
568
    is($items->[0]->{barcode}, $item1->barcode, 'Items sorted as expected by availability');
568
    is($items->[0]->{barcode}, $item1->barcode, 'Items sorted as expected by availability');
569
569
570
    subtest 'Search items by ISSN and ISBN with variations' => sub {
571
        plan tests => 4;
572
573
        my $marc_record = MARC::Record->new;
574
        # Prepare ISBN for biblio:
575
        $marc_record->append_fields( MARC::Field->new( '020', '', '', 'a' => '9780136019701' ) );
576
        # Prepare ISSN for biblio:
577
        $marc_record->append_fields( MARC::Field->new( '022', '', '', 'a' => '2434561X' ) );
578
        my ( $isbnissn_biblionumber ) = AddBiblio( $marc_record, '' );
579
        my $isbnissn_biblio = Koha::Biblios->find($isbnissn_biblionumber);
580
581
        my $item = $builder->build_sample_item(
582
            {
583
                biblionumber => $isbnissn_biblio->biblionumber,
584
            }
585
        );
586
        my $item_itemnumber = $item->itemnumber;
587
588
        my $filter_isbn = {
589
            field => 'isbn',
590
            query => '978013-6019701',
591
            operator => 'like',
592
        };
593
594
        t::lib::Mocks::mock_preference('SearchWithISBNVariations', 0);
595
        ($items, $total_results) = SearchItems($filter_isbn);
596
        is($total_results, 0, "Search items finds ISBN, no variations");
597
598
        t::lib::Mocks::mock_preference('SearchWithISBNVariations', 1);
599
        ($items, $total_results) = SearchItems($filter_isbn);
600
        is($total_results, 1, "Search items finds ISBN with variations");
601
602
        my $filter_issn = {
603
            field => 'issn',
604
            query => '2434-561X',
605
            operator => 'like',
606
        };
607
608
        t::lib::Mocks::mock_preference('SearchWithISSNVariations', 0);
609
        ($items, $total_results) = SearchItems($filter_issn);
610
        is($total_results, 0, "Search items finds ISSN, no variations");
611
612
        t::lib::Mocks::mock_preference('SearchWithISSNVariations', 1);
613
        ($items, $total_results) = SearchItems($filter_issn);
614
        is($total_results, 1, "Search items finds ISSN with variations");
615
    };
616
570
    $schema->storage->txn_rollback;
617
    $schema->storage->txn_rollback;
571
};
618
};
572
619
573
- 

Return to bug 23919