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

(-)a/t/db_dependent/Items/GetHostItemsInfo.t (-1 / +41 lines)
Line 0 Link Here
0
- 
1
use Modern::Perl;
2
3
use Test::More tests => 1;
4
use t::lib::Mocks;
5
use t::lib::TestBuilder;
6
7
use C4::Items;
8
use Koha::Database;
9
10
my $schema = Koha::Database->new->schema;
11
$schema->storage->txn_begin;
12
13
subtest 'GetHostItemsInfo' => sub {
14
    plan tests => 3;
15
16
    my $builder = t::lib::TestBuilder->new;
17
    my $bib1 = $builder->build({ source => 'Biblio' });
18
    my $itm1 = $builder->build({ source => 'Item', value => { biblionumber => $bib1->{biblionumber} }});
19
    my $itm2 = $builder->build({ source => 'Item', value => { biblionumber => $bib1->{biblionumber} }});
20
    my $marc = MARC::Record->new;
21
    $marc->append_fields(
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} ),
25
    );
26
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' );
31
32
    t::lib::Mocks::mock_preference('EasyAnalyticalRecords', 1);
33
    @a = C4::Items::GetHostItemsInfo( $marc );
34
    is( @a, 2, 'GetHostItemsInfo returns two items for MARC21' );
35
36
    t::lib::Mocks::mock_preference('marcflavour', 'UNIMARC');
37
    @a = C4::Items::GetHostItemsInfo( $marc );
38
    is( @a, 1, 'GetHostItemsInfo returns one item for UNIMARC' );
39
};
40
41
$schema->storage->txn_rollback;

Return to bug 20702