Bug 5327: Little change to Record.t
[koha.git] / t / Record.t
1 #!/usr/bin/perl
2 #
3 # This Koha test module is a stub!  
4 # Add more tests here!!!
5
6 use strict;
7 use warnings;
8
9 use Test::More tests => 10;
10 use MARC::Record;
11
12 BEGIN {
13         use_ok('C4::Record');
14 }
15
16 #my ($marc,$to_flavour,$from_flavour,$encoding) = @_;
17
18 my @marcarray=marc2marc;
19 is ($marcarray[0],"Feature not yet implemented\n","error works");
20
21 my $marc=new MARC::Record;
22 my $marcxml=marc2marcxml($marc);
23 my $testxml=qq(<?xml version="1.0" encoding="UTF-8"?>
24 <record
25     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
26     xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"
27     xmlns="http://www.loc.gov/MARC21/slim">
28
29   <leader>         a              </leader>
30 </record>
31 );
32 is ($marcxml, $testxml, "testing marc2xml");
33
34 my $rawmarc=$marc->as_usmarc;
35 $marcxml=marc2marcxml($rawmarc);
36 $testxml=qq(<?xml version="1.0" encoding="UTF-8"?>
37 <record
38     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
39     xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"
40     xmlns="http://www.loc.gov/MARC21/slim">
41
42   <leader>00026    a2200025   4500</leader>
43 </record>
44 );
45 is ($marcxml, $testxml, "testing marc2xml");
46
47 my $marcconvert=marcxml2marc($marcxml);
48 is ($marcconvert->as_xml,$marc->as_xml, "testing xml2marc");
49
50 my $marcdc=marc2dcxml($marc);
51 my $test2xml=qq(<?xml version="1.0" encoding="UTF-8"?>
52 <metadata
53   xmlns="http://example.org/myapp/"
54   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55   xsi:schemaLocation="http://example.org/myapp/ http://example.org/myapp/schema.xsd"
56   xmlns:dc="http://purl.org/dc/elements/1.1/"
57   xmlns:dcterms="http://purl.org/dc/terms/">
58 </metadata>);
59
60 is ($marcdc, $test2xml, "testing marc2dcxml");
61
62 my $marcqualified=marc2dcxml($marc,1);
63 my $test3xml=qq(<?xml version="1.0" encoding="UTF-8"?>
64 <metadata
65   xmlns="http://example.org/myapp/"
66   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
67   xsi:schemaLocation="http://example.org/myapp/ http://example.org/myapp/schema.xsd"
68   xmlns:dc="http://purl.org/dc/elements/1.1/"
69   xmlns:dcterms="http://purl.org/dc/terms/">
70 </metadata>);
71
72 is ($marcqualified, $test3xml, "testing marcQualified");
73
74 my $mods=marc2modsxml($marc);
75 my $test4xml=qq(<?xml version="1.0" encoding="UTF-8"?>
76 <mods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.loc.gov/mods/v3" version="3.1" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-1.xsd">
77   <typeOfResource/>
78   <originInfo>
79     <issuance/>
80   </originInfo>
81   <recordInfo/>
82 </mods>
83 );
84
85 is ($mods, $test4xml, "testing marc2mosxml");
86
87 my $field = MARC::Field->new('245','','','a' => "Harry potter");
88 $marc->append_fields($field);
89
90 #my $endnote=marc2endnote($marc->as_usmarc);
91 #print $endnote;
92
93 my $bibtex=marc2bibtex($marc);
94 my $test5xml=qq(\@book{,
95         title = "Harry potter"
96 }
97 );
98
99 is ($bibtex, $test5xml, "testing bibtex");
100
101 my @entity=C4::Record::_entity_encode("Bj√∂rn");
102 is ($entity[0], "Bj&#xC3;&#xB6;rn", "Html umlauts");
103
104
105
106
107
108
109
110