3 # This Koha test module is a stub!
4 # Add more tests here!!!
8 use Test
::More tests
=> 17;
16 my $isbn = '0590353403';
17 my $title = 'Foundation';
19 my $marc_record=MARC
::Record
->new;
20 my $field = MARC
::Field
->new('020','','','a' => $isbn);
21 $marc_record->append_fields($field);
22 my($biblionumber,$biblioitemnumber) = AddBiblio
($marc_record,'');
23 my $data = &GetBiblioData
($biblionumber);
24 is
($data->{Title
},undef,'Makes sure title field in biblio is empty.');
26 $field = MARC
::Field
->new('245','','','a' => $title);
27 $marc_record->append_fields($field);
28 ModBiblio
($marc_record,$biblionumber,'');
29 $data = &GetBiblioData
($biblionumber);
30 is
($data->{title
},$title,'uses ModBiblio to add a title to the previously created record and checks that its there.');
31 is
($data->{isbn
},$isbn,'Makes sure the isbn is still there after using ModBiblio.');
33 my $itemdata = &GetBiblioItemData
($biblioitemnumber);
34 is
($itemdata->{title
},$title,'First test of GetBiblioItemData to get same result of previous two GetBiblioData tests.');
35 is
($itemdata->{isbn
},$isbn,'Second test checking it returns the correct isbn.');
38 $field = MARC
::Field
->new(
40 'a' => 'Auction catalogs',
44 $marc_record->append_fields($field);
45 $success = ModBiblio
($marc_record,$biblionumber,'');
50 ok
($success, "ModBiblio handles authority-linked 655");
53 $field->delete_subfields('a');
54 $marc_record->append_fields($field);
55 $success = ModBiblio
($marc_record,$biblionumber,'');
60 ok
($success, "ModBiblio handles 655 with authority link but no heading");
63 $field->delete_subfields('9');
64 $marc_record->append_fields($field);
65 $success = ModBiblio
($marc_record,$biblionumber,'');
70 ok
($success, "ModBiblio handles 655 with no subfields");
74 $issns = GetMarcISSN
( $marc_record, 'MARC21' );
75 is
( $issns->[0], undef,
76 'GetMarcISSN handles records without 022 (list is empty)' );
77 is
( scalar @
$issns, 0, 'GetMarcISSN handles records without 022 (number of elements correct)' );
79 my $issn = '1234-1234';
80 $field = MARC
::Field
->new( '022', '', '', 'a', => $issn );
81 $marc_record->append_fields($field);
82 $issns = GetMarcISSN
( $marc_record, 'MARC21' );
83 is
( $issns->[0], $issn,
84 'GetMarcISSN handles records with single 022 (first element is correct)' );
85 is
( scalar @
$issns, 1, 'GetMARCISSN handles records with single 022 (number of elements correct)'
88 my @more_issns = qw
/1111-1111 2222-2222 3333-3333/;
89 foreach (@more_issns) {
90 $field = MARC
::Field
->new( '022', '', '', 'a', => $_ );
91 $marc_record->append_fields($field);
93 $issns = GetMarcISSN
( $marc_record, 'MARC21' );
94 is
( scalar @
$issns, 4, 'GetMARCISSN handles records with multiple 022 (number of elements correct)'
97 # Testing GetMarcControlnumber
99 $controlnumber = GetMarcControlnumber
( $marc_record, 'MARC21' );
100 is
( $controlnumber, '', 'GetMarcControlnumber handles records without 001' );
102 $field = MARC
::Field
->new( '001', '' );
103 $marc_record->append_fields($field);
104 $controlnumber = GetMarcControlnumber
( $marc_record, 'MARC21' );
105 is
( $controlnumber, '', 'GetMarcControlnumber handles records with empty 001' );
107 $field = $marc_record->field('001');
108 $field->update('123456789X');
109 $controlnumber = GetMarcControlnumber
( $marc_record, 'MARC21' );
110 is
( $controlnumber, '123456789X', 'GetMarcControlnumber handles records with 001' );
112 # clean up after ourselves
113 DelBiblio
($biblionumber);