X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=t%2Fdb_dependent%2FRecord.t;h=613e5ea7ea63448625b05d0eb8e926b9e95d1c23;hb=3ef3ecfe99e219fda854ca57c652e3c52a7f47d7;hp=2e0444911cb34a32ca63cd09c4eb50274ff4d957;hpb=b5ee2f201bed91a38ff2c1c527cbf19adc76fabc;p=koha.git
diff --git a/t/db_dependent/Record.t b/t/db_dependent/Record.t
index 2e0444911c..613e5ea7ea 100755
--- a/t/db_dependent/Record.t
+++ b/t/db_dependent/Record.t
@@ -1,19 +1,22 @@
#!/usr/bin/perl
-#
-# This Koha test module is a stub!
-# Add more tests here!!!
-use strict;
-use warnings;
+use Modern::Perl;
-use Test::More tests => 10;
+use Test::More tests => 14;
use MARC::Record;
+use t::lib::Mocks;
+use C4::Context;
+use Koha::Database;
+
BEGIN {
use_ok('C4::Record');
}
-#my ($marc,$to_flavour,$from_flavour,$encoding) = @_;
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
+
+t::lib::Mocks::mock_preference( "BibtexExportAdditionalFields", q{} );
my @marcarray=marc2marc;
is ($marcarray[0],"Feature not yet implemented\n","error works");
@@ -47,32 +50,47 @@ 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 $marcrdfdc=marc2dcxml( $marc, undef, undef, "rdfdc" );
+my $test4Axml=qq(
+
+
+
+
+);
+
+is ($marcrdfdc, $test4Axml, "testing RDFDC Metadata");
+
+my $marcdc=marc2dcxml( $marc, undef, undef, "dc" );
+my $test4Bxml=qq(
+
+
+
+
+);
+
+is ($marcrdfdc, $test4Bxml, "testing DC Metadata");
my $mods=marc2modsxml($marc);
-my $test4xml=qq(
+my $test5xml=qq(
@@ -82,21 +100,56 @@ my $test4xml=qq(
);
-is ($mods, $test4xml, "testing marc2mosxml");
+is ($mods, $test5xml, "testing marc2modsxml");
+$marc->append_fields(MARC::Field->new(
+ '100', ' ', ' ', a => 'Rowling, J.K.'
+));
my $field = MARC::Field->new('245','','','a' => "Harry potter");
$marc->append_fields($field);
+$marc->append_fields(MARC::Field->new(
+ '260', ' ', ' ', b => 'Scholastic', c => '2001'
+));
#my $endnote=marc2endnote($marc->as_usmarc);
#print $endnote;
-my $bibtex=marc2bibtex($marc);
-my $test5xml=qq(\@book{,
- title = "Harry potter"
+my $bibtex=marc2bibtex($marc, 'testID');
+my $test6xml=qq(\@book{testID,
+ author = {Rowling, J.K.},
+ title = {Harry potter},
+ publisher = {Scholastic},
+ year = {2001}
}
);
-is ($bibtex, $test5xml, "testing bibtex");
+is ($bibtex, $test6xml, "testing bibtex");
+
+t::lib::Mocks::mock_preference( "BibtexExportAdditionalFields", "'\@': 260\$b\ntest: 260\$b" );
+$bibtex = marc2bibtex( $marc, 'testID' );
+my $test7xml = qq(\@Scholastic{testID,
+\tauthor = {Rowling, J.K.},
+\ttitle = {Harry potter},
+\tpublisher = {Scholastic},
+\tyear = {2001},
+\ttest = {Scholastic}
+}
+);
+is( $bibtex, $test7xml, "testing bibtex" );
+t::lib::Mocks::mock_preference( "BibtexExportAdditionalFields", q{} );
+
+$marc->append_fields(MARC::Field->new(
+ '264', '3', '1', b => 'Reprints', c => '2011'
+));
+$bibtex = marc2bibtex($marc, 'testID');
+my $rdabibtex = qq(\@book{testID,
+ author = {Rowling, J.K.},
+ title = {Harry potter},
+ publisher = {Reprints},
+ year = {2011}
+}
+);
+is ($bibtex, $rdabibtex, "testing bibtex with RDA 264 field");
my @entity=C4::Record::_entity_encode("Björn");
is ($entity[0], "Björn", "Html umlauts");