5 use Test
::More tests
=> 14;
15 my $dbh = C4
::Context
->dbh;
17 $dbh->{AutoCommit
} = 0;
18 $dbh->{RaiseError
} = 1;
20 t
::lib
::Mocks
::mock_preference
( "BibtexExportAdditionalFields", q{} );
22 my @marcarray=marc2marc
;
23 is
($marcarray[0],"Feature not yet implemented\n","error works");
25 my $marc=new MARC
::Record
;
26 my $marcxml=marc2marcxml
($marc);
27 my $testxml=qq(<?xml version
="1.0" encoding
="UTF-8"?
>
29 xmlns
:xsi
="http://www.w3.org/2001/XMLSchema-instance"
30 xsi
:schemaLocation
="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"
31 xmlns
="http://www.loc.gov/MARC21/slim">
36 is
($marcxml, $testxml, "testing marc2xml");
38 my $rawmarc=$marc->as_usmarc;
39 $marcxml=marc2marcxml
($rawmarc);
40 $testxml=qq(<?xml version
="1.0" encoding
="UTF-8"?
>
42 xmlns
:xsi
="http://www.w3.org/2001/XMLSchema-instance"
43 xsi
:schemaLocation
="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"
44 xmlns
="http://www.loc.gov/MARC21/slim">
46 <leader
>00026 a2200025
4500</leader
>
49 is
($marcxml, $testxml, "testing marc2xml");
51 my $marcconvert=marcxml2marc
($marcxml);
52 is
($marcconvert->as_xml,$marc->as_xml, "testing xml2marc");
54 my $marcsrwdc=marc2dcxml
( $marc, undef, undef, "srwdc" );
55 my $test2xml=qq(<?xml version
="1.0" encoding
="UTF-8"?
>
56 <srw_dc
:dc xmlns
:srw_dc
="info:srw/schema/1/dc-schema" xmlns
:xsi
="http://www.w3.org/2001/XMLSchema-instance" xsi
:schemaLocation
="info:srw/schema/1/dc-schema http://www.loc.gov/z3950/agency/zing/srw/dc-schema.xsd">
57 <type xmlns
="http://purl.org/dc/elements/1.1/"/>
61 is
($marcsrwdc, $test2xml, "testing SRWDC Metadata");
63 my $marcoaidc=marc2dcxml
( $marc, undef, undef, "oaidc" );
64 my $test3xml=qq(<?xml version
="1.0" encoding
="UTF-8"?
>
65 <oai_dc
:dc xmlns
:oai_dc
="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns
:dc
="http://purl.org/dc/elements/1.1/" xmlns
:xsi
="http://www.w3.org/2001/XMLSchema-instance" xsi
:schemaLocation
="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
71 is
($marcoaidc, $test3xml, "testing OAIDC Metadata");
73 my $marcrdfdc=marc2dcxml
( $marc, undef, undef, "rdfdc" );
74 my $test4Axml=qq(<?xml version
="1.0" encoding
="UTF-8"?
>
75 <rdf
:Description xmlns
:rdf
="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns
:dc
="http://purl.org/dc/elements/1.1/">
81 is
($marcrdfdc, $test4Axml, "testing RDFDC Metadata");
83 my $marcdc=marc2dcxml
( $marc, undef, undef, "dc" );
84 my $test4Bxml=qq(<?xml version
="1.0" encoding
="UTF-8"?
>
85 <rdf
:Description xmlns
:rdf
="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns
:dc
="http://purl.org/dc/elements/1.1/">
91 is
($marcrdfdc, $test4Bxml, "testing DC Metadata");
93 my $mods=marc2modsxml
($marc);
94 my $test5xml=qq(<?xml version
="1.0" encoding
="UTF-8"?
>
95 <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">
104 is
($mods, $test5xml, "testing marc2modsxml");
106 $marc->append_fields(MARC
::Field
->new(
107 '100', ' ', ' ', a
=> 'Rowling, J.K.'
109 my $field = MARC
::Field
->new('245','','','a' => "Harry potter");
110 $marc->append_fields($field);
111 $marc->append_fields(MARC
::Field
->new(
112 '260', ' ', ' ', b
=> 'Scholastic', c
=> '2001'
115 #my $endnote=marc2endnote($marc->as_usmarc);
118 my $bibtex=marc2bibtex
($marc, 'testID');
119 my $test6xml=qq(\
@book{testID
,
120 author
= {Rowling
, J
.K
.},
121 title
= {Harry potter
},
122 publisher
= {Scholastic
},
127 is
($bibtex, $test6xml, "testing bibtex");
129 t
::lib
::Mocks
::mock_preference
( "BibtexExportAdditionalFields", "'\@': 260\$b\ntest: 260\$b" );
130 $bibtex = marc2bibtex
( $marc, 'testID' );
131 my $test7xml = qq(\
@Scholastic{testID
,
132 \tauthor
= {Rowling
, J
.K
.},
133 \ttitle
= {Harry potter
},
134 \tpublisher
= {Scholastic
},
136 \ttest
= {Scholastic
}
139 is
( $bibtex, $test7xml, "testing bibtex" );
140 t
::lib
::Mocks
::mock_preference
( "BibtexExportAdditionalFields", q{} );
142 $marc->append_fields(MARC
::Field
->new(
143 '264', '3', '1', b
=> 'Reprints', c
=> '2011'
145 $bibtex = marc2bibtex
($marc, 'testID');
146 my $rdabibtex = qq(\
@book{testID
,
147 author
= {Rowling
, J
.K
.},
148 title
= {Harry potter
},
149 publisher
= {Reprints
},
153 is
($bibtex, $rdabibtex, "testing bibtex with RDA 264 field");
155 my @entity=C4
::Record
::_entity_encode
("Björn");
156 is
($entity[0], "Björn", "Html umlauts");