|
Lines 680-686
subtest 'Koha::Item(s) tests' => sub {
Link Here
|
| 680 |
}; |
680 |
}; |
| 681 |
|
681 |
|
| 682 |
subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub { |
682 |
subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub { |
| 683 |
plan tests => 8; |
683 |
plan tests => 11; |
| 684 |
|
684 |
|
| 685 |
$schema->storage->txn_begin(); |
685 |
$schema->storage->txn_begin(); |
| 686 |
|
686 |
|
|
Lines 724-729
subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub {
Link Here
|
| 724 |
push @itemnumbers, $itemnumber; |
724 |
push @itemnumbers, $itemnumber; |
| 725 |
} |
725 |
} |
| 726 |
|
726 |
|
|
|
727 |
my $host_item = $builder->build_sample_item({ homebranch => $library2->{branchcode} }); |
| 728 |
my $child_field = PrepHostMarcField( $host_item->biblionumber, $host_item->itemnumber, 'MARC21'); |
| 729 |
my $child_record = $biblio->metadata->record; |
| 730 |
$child_record->append_fields($child_field); |
| 731 |
ModBiblio( $child_record, $biblio->biblionumber, '' ); |
| 732 |
|
| 727 |
# Emptied the OpacHiddenItems pref |
733 |
# Emptied the OpacHiddenItems pref |
| 728 |
t::lib::Mocks::mock_preference( 'OpacHiddenItems', '' ); |
734 |
t::lib::Mocks::mock_preference( 'OpacHiddenItems', '' ); |
| 729 |
|
735 |
|
|
Lines 745-750
subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub {
Link Here
|
| 745 |
embed_items => 1 }); |
751 |
embed_items => 1 }); |
| 746 |
is_deeply( $record, $marc_with_items, 'A direct call to GetMarcBiblio with items matches'); |
752 |
is_deeply( $record, $marc_with_items, 'A direct call to GetMarcBiblio with items matches'); |
| 747 |
|
753 |
|
|
|
754 |
C4::Biblio::EmbedItemsInMarcBiblio({ |
| 755 |
marc_record => $record, |
| 756 |
biblionumber => $biblio->biblionumber, |
| 757 |
embed_host_items => 1 |
| 758 |
}); |
| 759 |
@items = $record->field($itemfield); |
| 760 |
is( scalar @items, $number_of_items + 1, 'Should return all items plus host items' ); |
| 761 |
|
| 762 |
$marc_with_items = C4::Biblio::GetMarcBiblio({ |
| 763 |
biblionumber => $biblio->biblionumber, |
| 764 |
embed_items => 1, |
| 765 |
embed_host_items => 1 |
| 766 |
}); |
| 767 |
is_deeply( $record, $marc_with_items, 'A direct call to GetMarcBiblio with items matches'); |
| 768 |
|
| 748 |
C4::Biblio::EmbedItemsInMarcBiblio({ |
769 |
C4::Biblio::EmbedItemsInMarcBiblio({ |
| 749 |
marc_record => $record, |
770 |
marc_record => $record, |
| 750 |
biblionumber => $biblio->biblionumber, |
771 |
biblionumber => $biblio->biblionumber, |
|
Lines 782-787
subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub {
Link Here
|
| 782 |
'For OPAC, the pref OpacHiddenItems should have been take into account. Only items with homebranch ne CPL should have been embedded' |
803 |
'For OPAC, the pref OpacHiddenItems should have been take into account. Only items with homebranch ne CPL should have been embedded' |
| 783 |
); |
804 |
); |
| 784 |
|
805 |
|
|
|
806 |
C4::Biblio::EmbedItemsInMarcBiblio({ |
| 807 |
marc_record => $record, |
| 808 |
biblionumber => $biblio->biblionumber, |
| 809 |
opac => 1, |
| 810 |
embed_host_items => 1 |
| 811 |
}); |
| 812 |
@items = $record->field($itemfield); |
| 813 |
is( |
| 814 |
scalar @items, |
| 815 |
$number_of_items - $number_of_items_with_homebranch_is_CPL + 1, |
| 816 |
'For OPAC, the pref OpacHiddenItems should have been take into account and host items embedded. Only items with homebranch ne CPL should have been embedded' |
| 817 |
); |
| 818 |
|
| 819 |
|
| 785 |
$opachiddenitems = " |
820 |
$opachiddenitems = " |
| 786 |
homebranch: ['$library1->{branchcode}', '$library2->{branchcode}']"; |
821 |
homebranch: ['$library1->{branchcode}', '$library2->{branchcode}']"; |
| 787 |
t::lib::Mocks::mock_preference( 'OpacHiddenItems', $opachiddenitems ); |
822 |
t::lib::Mocks::mock_preference( 'OpacHiddenItems', $opachiddenitems ); |
| 788 |
- |
|
|