Bug 25416: Unit tests
authorTomas Cohen Arazi <tomascohen@theke.io>
Mon, 11 May 2020 11:38:49 +0000 (08:38 -0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Fri, 15 May 2020 08:33:22 +0000 (09:33 +0100)
This patch adds tests for the new 'feature': i.e. searchResults passes
the added $xslt_variables to the XSLTParse4Display method.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

t/db_dependent/Search.t

index 34d4e33..771a7f4 100644 (file)
@@ -492,6 +492,17 @@ ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'
     }
     is ($allavailable, 'true', 'All records have at least one item available');
 
+    use Test::MockModule;
+    my $mocked_xslt = Test::MockModule->new('Koha::XSLT::Base');
+    $mocked_xslt->mock( 'transform', sub {
+        my ($self, $xml) = @_;
+        return $xml;
+    });
+
+    @newresults = searchResults({'interface'=>'opac'}, $query_desc, $results_hashref->{'biblioserver'}->{'hits'}, 17, 0, 0,
+        $results_hashref->{'biblioserver'}->{"RECORDS"}, { anonymous_session => 1 });
+
+    like( $newresults[0]->{XSLTResultsRecord}, qr/<variable name="anonymous_session">1<\/variable>/, "Variable injected correctly" );
 
     ( $error, $query, $simple_query, $query_cgi,
     $query_desc, $limit, $limit_cgi, $limit_desc,
@@ -842,7 +853,7 @@ sub run_unimarc_search_tests {
 }
 
 subtest 'MARC21 + DOM' => sub {
-    plan tests => 84;
+    plan tests => 85;
     run_marc21_search_tests();
 };