Bug 17377: Add tests for json2marc
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 29 Sep 2016 15:41:53 +0000 (16:41 +0100)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 18 Nov 2016 13:53:20 +0000 (13:53 +0000)
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
t/db_dependent/Koha_SearchEngine_Elasticsearch_Search.t

index 2bcd83c..2a77dad 100644 (file)
@@ -17,7 +17,7 @@
 
 use Modern::Perl;
 
-use Test::More tests => 10;
+use Test::More tests => 11;
 
 use Koha::SearchEngine::Elasticsearch::QueryBuilder;
 
@@ -57,4 +57,26 @@ SKIP: {
 
 }
 
+subtest 'json2marc' => sub {
+    plan tests => 4;
+    my $leader = '00626nam a2200193   4500';
+    my $_001 = 42;
+    my $_010a = '123456789';
+    my $_010d = 145;
+    my $_200a = 'a title';
+    my $json = [ # It's not a JSON, see the POD of json2marc
+        [ 'LDR', undef, undef, '_', $leader ],
+        [ '001', undef, undef, '_', $_001 ],
+        [ '010', ' ', ' ', 'a', $_010a, 'd', $_010d ],
+        [ '200', '1', ' ', 'a', $_200a, ], # Yes UNIMARC but we don't mind here
+    ];
+
+    my $marc = $searcher->json2marc( $json );
+    is( $marc->leader, $leader, );
+    is( $marc->field('001')->data, $_001, );
+    is( $marc->subfield('010', 'a'), $_010a, );
+    is( $marc->subfield('200', 'a'), $_200a, );
+
+};
+
 1;