Lines 408-414
subtest q{Test Koha::Database->schema()->resultset('Item')->itemtype()} => sub {
Link Here
|
408 |
}; |
408 |
}; |
409 |
|
409 |
|
410 |
subtest 'SearchItems test' => sub { |
410 |
subtest 'SearchItems test' => sub { |
411 |
plan tests => 19; |
411 |
plan tests => 20; |
412 |
|
412 |
|
413 |
$schema->storage->txn_begin; |
413 |
$schema->storage->txn_begin; |
414 |
my $dbh = C4::Context->dbh; |
414 |
my $dbh = C4::Context->dbh; |
Lines 666-671
subtest 'SearchItems test' => sub {
Link Here
|
666 |
($items, $total_results) = SearchItems($filter,$params); |
666 |
($items, $total_results) = SearchItems($filter,$params); |
667 |
is($items->[0]->{barcode}, $item1->barcode, 'Items sorted as expected by availability'); |
667 |
is($items->[0]->{barcode}, $item1->barcode, 'Items sorted as expected by availability'); |
668 |
|
668 |
|
|
|
669 |
subtest 'Search items by ISSN and ISBN with variations' => sub { |
670 |
plan tests => 4; |
671 |
|
672 |
my $marc_record = MARC::Record->new; |
673 |
# Prepare ISBN for biblio: |
674 |
$marc_record->append_fields( MARC::Field->new( '020', '', '', 'a' => '9780136019701' ) ); |
675 |
# Prepare ISSN for biblio: |
676 |
$marc_record->append_fields( MARC::Field->new( '022', '', '', 'a' => '2434561X' ) ); |
677 |
my ( $isbnissn_biblionumber ) = AddBiblio( $marc_record, '' ); |
678 |
my $isbnissn_biblio = Koha::Biblios->find($isbnissn_biblionumber); |
679 |
|
680 |
my $item = $builder->build_sample_item( |
681 |
{ |
682 |
biblionumber => $isbnissn_biblio->biblionumber, |
683 |
} |
684 |
); |
685 |
my $item_itemnumber = $item->itemnumber; |
686 |
|
687 |
my $filter_isbn = { |
688 |
field => 'isbn', |
689 |
query => '978013-6019701', |
690 |
operator => 'like', |
691 |
}; |
692 |
|
693 |
t::lib::Mocks::mock_preference('SearchWithISBNVariations', 0); |
694 |
($items, $total_results) = SearchItems($filter_isbn); |
695 |
is($total_results, 0, "Search items finds ISBN, no variations"); |
696 |
|
697 |
t::lib::Mocks::mock_preference('SearchWithISBNVariations', 1); |
698 |
($items, $total_results) = SearchItems($filter_isbn); |
699 |
is($total_results, 1, "Search items finds ISBN with variations"); |
700 |
|
701 |
my $filter_issn = { |
702 |
field => 'issn', |
703 |
query => '2434-561X', |
704 |
operator => 'like', |
705 |
}; |
706 |
|
707 |
t::lib::Mocks::mock_preference('SearchWithISSNVariations', 0); |
708 |
($items, $total_results) = SearchItems($filter_issn); |
709 |
is($total_results, 0, "Search items finds ISSN, no variations"); |
710 |
|
711 |
t::lib::Mocks::mock_preference('SearchWithISSNVariations', 1); |
712 |
($items, $total_results) = SearchItems($filter_issn); |
713 |
is($total_results, 1, "Search items finds ISSN with variations"); |
714 |
}; |
715 |
|
669 |
$schema->storage->txn_rollback; |
716 |
$schema->storage->txn_rollback; |
670 |
}; |
717 |
}; |
671 |
|
718 |
|
672 |
- |
|
|