Bug 24756: Fix D8 and U18 failures for Koha/XSLT/Security.t
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Fri, 28 Feb 2020 08:20:43 +0000 (08:20 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Fri, 28 Feb 2020 08:44:07 +0000 (08:44 +0000)
Instead of warning_like, we eventually catch multiple warnings and look
if we catch one specific warn and not catch another specific one.

Test plan:
Run t/db_dependent/Koha/XSLT/Security.t on D8, D9, D10 or U18.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Passes on D8 and D9 for me.
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

t/db_dependent/Koha/XSLT/Security.t

index 67a27ad..41b72aa 100644 (file)
@@ -19,7 +19,7 @@
 
 use Modern::Perl;
 use File::Temp qw/tempfile/;
-use Test::More tests => 7;
+use Test::More tests => 8;
 use Test::Warn;
 
 use Koha::XSLT::Base;
@@ -120,9 +120,13 @@ $xslt=<<"EOT";
 EOT
 $xslt_file = mytempfile($xslt);
 $engine->print_warns(1);
-warning_like { $output= $engine->transform( "<ignored/>", $xslt_file ); }
-    qr/I\/O warning : failed to load external entity/,
-    'Remote import does not fail on read_net';
+{
+    my @warn;
+    local $SIG{__WARN__} = sub { push @warn, $_[0]; };
+    $output= $engine->transform( "<ignored/>", $xslt_file );
+    is( ( grep { /failed to load external/ } @warn ), 1, 'Expected import error' );
+    is( ( grep { /read_net/ } @warn ), 0, 'No read_net warn for remote import' );
+}
 
 sub mytempfile {
     my ( $fh, $fn ) = tempfile( SUFFIX => '.xsl', UNLINK => 1 );