From 550b3debc917d7907ac6b5f37e0e0f852de8dc43 Mon Sep 17 00:00:00 2001 From: Hector Castro Date: Mon, 9 Nov 2015 17:17:28 -0600 Subject: [PATCH] Bug 13642 - Add Unit test for C4::Record::marc2dcxml Add Unit test for C4::Record::marc2dcxml To test: prove t/db_dependent/Record.t prove t/db_dependent/Record/Record.t Signed-off-by: Frederic Demians Signed-off-by: Jonathan Druart --- t/db_dependent/Record.t | 55 +++++++++++++++++++++++------------------- t/db_dependent/Record/Record.t | 5 ++-- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/t/db_dependent/Record.t b/t/db_dependent/Record.t index 8e806d7..8ad07fd 100755 --- a/t/db_dependent/Record.t +++ b/t/db_dependent/Record.t @@ -2,7 +2,7 @@ use Modern::Perl; -use Test::More tests => 12; +use Test::More tests => 13; use MARC::Record; use C4::Context; @@ -50,32 +50,37 @@ is ($marcxml, $testxml, "testing marc2xml"); my $marcconvert=marcxml2marc($marcxml); is ($marcconvert->as_xml,$marc->as_xml, "testing xml2marc"); -my $marcdc=marc2dcxml($marc); +my $marcsrwdc=marc2dcxml( $marc, undef, undef, "srwdc" ); my $test2xml=qq( - -); + + + +); -is ($marcdc, $test2xml, "testing marc2dcxml"); +is ($marcsrwdc, $test2xml, "testing SRWDC Metadata"); -my $marcqualified=marc2dcxml($marc,1); +my $marcoaidc=marc2dcxml( $marc, undef, undef, "oaidc" ); my $test3xml=qq( - -); + + + + +); -is ($marcqualified, $test3xml, "testing marcQualified"); +is ($marcoaidc, $test3xml, "testing OAIDC Metadata"); -my $mods=marc2modsxml($marc); +my $marcrdfdc=marc2dcxml( $marc, undef, undef, "rdfdc" ); my $test4xml=qq( + + + + +); + +is ($marcrdfdc, $test4xml, "testing OAIDC Metadata"); + +my $mods=marc2modsxml($marc); +my $test5xml=qq( @@ -85,7 +90,7 @@ my $test4xml=qq( ); -is ($mods, $test4xml, "testing marc2modsxml"); +is ($mods, $test5xml, "testing marc2modsxml"); $marc->append_fields(MARC::Field->new( '100', ' ', ' ', a => 'Rowling, J.K.' @@ -100,7 +105,7 @@ $marc->append_fields(MARC::Field->new( #print $endnote; my $bibtex=marc2bibtex($marc, 'testID'); -my $test5xml=qq(\@book{testID, +my $test6xml=qq(\@book{testID, author = {Rowling, J.K.}, title = {Harry potter}, publisher = {Scholastic}, @@ -108,11 +113,11 @@ my $test5xml=qq(\@book{testID, } ); -is ($bibtex, $test5xml, "testing bibtex"); +is ($bibtex, $test6xml, "testing bibtex"); C4::Context->set_preference( "BibtexExportAdditionalFields", "'\@': 260\$b\ntest: 260\$b" ); $bibtex = marc2bibtex( $marc, 'testID' ); -my $test6xml = qq(\@Scholastic{testID, +my $test7xml = qq(\@Scholastic{testID, \tauthor = {Rowling, J.K.}, \ttitle = {Harry potter}, \tpublisher = {Scholastic}, @@ -120,7 +125,7 @@ my $test6xml = qq(\@Scholastic{testID, \ttest = {Scholastic} } ); -is( $bibtex, $test6xml, "testing bibtex" ); +is( $bibtex, $test7xml, "testing bibtex" ); C4::Context->set_preference( "BibtexExportAdditionalFields", q{} ); $marc->append_fields(MARC::Field->new( diff --git a/t/db_dependent/Record/Record.t b/t/db_dependent/Record/Record.t index 85ca720..0bbfb03 100755 --- a/t/db_dependent/Record/Record.t +++ b/t/db_dependent/Record/Record.t @@ -113,8 +113,9 @@ ok (!$error, 'no errors in conversion'); ok (($error,$marcxml) = marc2marcxml($marc21_utf8_combining_chars,'UTF-8','MARC21'), 'marc2marcxml - from UTF-8 to UTF-8 with combining characters (MARC21)'); ok (!$error, 'no errors in conversion'); -ok (($error,$dcxml) = marc2dcxml($marc21_utf8), 'marc2dcxml - from ISO-2709 to Dublin Core'); -ok (!$error, 'no errors in conversion'); +ok (eval{marc2dcxml($marc21_utf8, undef, undef, 'oaidc')}, 'marc2dcxml - from ISO-2709 to Dublin Core'); +$error = $@; +ok (!$error, 'no errors in conversion to DublinCore'); print "\n3. checking ability to alter encoding\n"; ok (($error,$marc) = changeEncoding($marc21_marc8,'MARC','MARC21','UTF-8'), 'changeEncoding - MARC21 from MARC-8 to UTF-8'); -- 2.1.0