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

(-)a/t/db_dependent/Items.t (-8 / +27 lines)
Lines 813-832 subtest '_mod_item_dates' => sub { Link Here
813
};
813
};
814
814
815
subtest 'get_hostitemnumbers_of' => sub {
815
subtest 'get_hostitemnumbers_of' => sub {
816
    plan tests => 1;
816
    plan tests => 3;
817
817
818
    $schema->storage->txn_begin;
818
    $schema->storage->txn_begin;
819
    t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
820
    my $builder = t::lib::TestBuilder->new;
819
821
820
    my $bib = MARC::Record->new();
822
    # Host item field without 0 or 9
821
    $bib->append_fields(
823
    my $bib1 = MARC::Record->new();
824
    $bib1->append_fields(
822
        MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'),
825
        MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'),
823
        MARC::Field->new('245', ' ', ' ', a => 'Silence in the library'),
826
        MARC::Field->new('245', ' ', ' ', a => 'Silence in the library'),
824
        MARC::Field->new('773', ' ', ' ', b => 'b without 0 or 9'),
827
        MARC::Field->new('773', ' ', ' ', b => 'b without 0 or 9'),
825
    );
828
    );
826
    my ($biblionumber, $bibitemnum) = AddBiblio($bib, '');
829
    my ($biblionumber1, $bibitemnum1) = AddBiblio($bib1, '');
827
830
    my @itemnumbers1 = C4::Items::get_hostitemnumbers_of( $biblionumber1 );
828
    my @itemnumbers = C4::Items::get_hostitemnumbers_of( $biblionumber );
831
    is( scalar @itemnumbers1, 0, '773 without 0 or 9');
829
    is( @itemnumbers, 0, );
832
833
    # Correct host item field, analytical records on
834
    t::lib::Mocks::mock_preference('EasyAnalyticalRecords', 1);
835
    my $hostitem = $builder->build_sample_item();
836
    my $bib2 = MARC::Record->new();
837
    $bib2->append_fields(
838
        MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'),
839
        MARC::Field->new('245', ' ', ' ', a => 'Silence in the library'),
840
        MARC::Field->new('773', ' ', ' ', 0 => $hostitem->biblionumber , 9 => $hostitem->itemnumber, b => 'b' ),
841
    );
842
    my ($biblionumber2, $bibitemnum2) = AddBiblio($bib2, '');
843
    my @itemnumbers2 = C4::Items::get_hostitemnumbers_of( $biblionumber2 );
844
    is( scalar @itemnumbers2, 1, '773 with 0 and 9, EasyAnalyticalRecords on');
845
846
    # Correct host item field, analytical records off
847
    t::lib::Mocks::mock_preference('EasyAnalyticalRecords', 0);
848
    @itemnumbers2 = C4::Items::get_hostitemnumbers_of( $biblionumber2 );
849
    is( scalar @itemnumbers2, 0, '773 with 0 and 9, EasyAnalyticalRecords off');
830
850
831
    $schema->storage->txn_rollback;
851
    $schema->storage->txn_rollback;
832
};
852
};
833
- 

Return to bug 22140