3 use Test::More tests => 1;
5 use t::lib::TestBuilder;
10 my $schema = Koha::Database->new->schema;
11 $schema->storage->txn_begin;
13 subtest 'GetHostItemsInfo' => sub {
16 my $builder = t::lib::TestBuilder->new;
17 my $bib1 = $builder->build_sample_biblio;
18 my $itm1 = $builder->build_sample_item({ biblionumber => $bib1->biblionumber });
19 my $itm2 = $builder->build_sample_item({ biblionumber => $bib1->biblionumber });
20 my $marc = MARC::Record->new;
22 MARC::Field->new( '461', '', '', 0 => $bib1->biblionumber, 9 => $itm1->itemnumber ),
23 MARC::Field->new( '773', '', '', 0 => $bib1->biblionumber, 9 => $itm1->itemnumber ),
24 MARC::Field->new( '773', '', '', 0 => $bib1->biblionumber, 9 => $itm2->itemnumber ),
27 t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
28 t::lib::Mocks::mock_preference('EasyAnalyticalRecords', 0);
29 my @a = C4::Items::GetHostItemsInfo( $marc );
30 is( @a, 0, 'GetHostItemsInfo returns empty list when pref is disabled' );
32 t::lib::Mocks::mock_preference('EasyAnalyticalRecords', 1);
33 @a = C4::Items::GetHostItemsInfo( $marc );
34 is( @a, 2, 'GetHostItemsInfo returns two items for MARC21' );
36 t::lib::Mocks::mock_preference('marcflavour', 'UNIMARC');
37 @a = C4::Items::GetHostItemsInfo( $marc );
38 is( @a, 1, 'GetHostItemsInfo returns one item for UNIMARC' );
41 $schema->storage->txn_rollback;