|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 20; |
20 |
use Test::More tests => 21; |
| 21 |
use Test::Warn; |
21 |
use Test::Warn; |
| 22 |
|
22 |
|
| 23 |
use C4::Biblio qw( AddBiblio ModBiblio ModBiblioMarc ); |
23 |
use C4::Biblio qw( AddBiblio ModBiblio ModBiblioMarc ); |
|
Lines 746-751
subtest 'get_marc_notes() UNIMARC tests' => sub {
Link Here
|
| 746 |
is( $notes->[0]->{marcnote}, 'Note1', 'First note' ); |
746 |
is( $notes->[0]->{marcnote}, 'Note1', 'First note' ); |
| 747 |
is( $notes->[1]->{marcnote}, 'Note2', 'Second note' ); |
747 |
is( $notes->[1]->{marcnote}, 'Note2', 'Second note' ); |
| 748 |
is( @$notes, 2, 'No more notes' ); |
748 |
is( @$notes, 2, 'No more notes' ); |
|
|
749 |
}; |
| 750 |
|
| 751 |
subtest 'get_host_item_entries() tests' => sub { |
| 752 |
|
| 753 |
plan tests => 2; |
| 754 |
|
| 755 |
$schema->storage->txn_begin; |
| 756 |
|
| 757 |
# Set up the host record and an item |
| 758 |
my $host_biblio = $builder->build_sample_biblio; |
| 759 |
my $host_item = $builder->build_sample_item({ biblionumber => $host_biblio->biblionumber }); |
| 760 |
|
| 761 |
# Set up the test record |
| 762 |
my $test_biblio = $builder->build_sample_biblio; |
| 763 |
my $record = $test_biblio->metadata->record; |
| 764 |
|
| 765 |
# Link the host item to the test record |
| 766 |
my $field = MARC::Field->new('245','','','a' => "Test title"); |
| 767 |
$record->append_fields( $field ); |
| 768 |
$field = MARC::Field->new('773','0','','0' => $host_biblio->biblionumber); |
| 769 |
$record->append_fields( $field ); |
| 770 |
$field = MARC::Field->new('773','0','','9' => $host_item->itemnumber); |
| 771 |
$record->append_fields( $field ); |
| 772 |
|
| 773 |
# Re-retrieve the record |
| 774 |
C4::Biblio::ModBiblio( $record, $test_biblio->biblionumber ); |
| 775 |
$test_biblio = Koha::Biblios->find( $test_biblio->biblionumber ); |
| 776 |
|
| 777 |
my $host_items = $test_biblio->get_host_item_entries; |
| 778 |
is( @{$host_items}, 1, "Correctly retrieved number of attached host item entries" ); |
| 779 |
my $test_host_biblionumber = @{$host_items}[0]->subfield('0'); |
| 780 |
is( $test_host_biblionumber, $host_biblio->biblionumber, "Correctly retrieved data about host item entry"); |
| 749 |
|
781 |
|
| 750 |
$schema->storage->txn_rollback; |
782 |
$schema->storage->txn_rollback; |
| 751 |
}; |
783 |
}; |