Bug 25504: Fix failing tests
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 1 Sep 2020 10:11:54 +0000 (12:11 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 1 Sep 2020 10:11:54 +0000 (12:11 +0200)
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
t/db_dependent/Koha/REST/Plugin/PluginRoutes.t

index 27af737..a1b3055 100644 (file)
@@ -20,6 +20,7 @@ use Modern::Perl;
 use Test::More tests => 4;
 use Test::Mojo;
 use Test::Warn;
+use Test::MockModule;
 
 use File::Basename;
 use t::lib::Mocks;
@@ -38,6 +39,12 @@ BEGIN {
 use Koha::Database;
 use Koha::Plugins;
 
+my $logger = Test::MockModule->new('Koha::Logger');
+$logger->mock('error', sub {
+    shift;
+    warn @_;
+});
+
 my $schema = Koha::Database->new->schema;
 
 subtest 'Bad plugins tests' => sub {
@@ -61,9 +68,10 @@ subtest 'Bad plugins tests' => sub {
 
     # initialize Koha::REST::V1 after mocking
     my $t;
-    warning_is
+    warning_like
         { $t = Test::Mojo->new('Koha::REST::V1'); }
-        'The resulting spec is invalid. Skipping Bad API Route Plugin',
+        [qr{Could not load REST API spec bundle: Invalid JSON specification},
+        qr{The resulting spec is invalid. Skipping Bad API Route Plugin},],
         'Bad plugins raise warning';
 
     my $routes = get_defined_routes($t);
@@ -139,9 +147,10 @@ subtest 'Anonymous access routes plugins tests' => sub {
 
     # initialize Koha::REST::V1 after mocking
     my $t;
-    warning_is
+    warning_like
         { $t = Test::Mojo->new('Koha::REST::V1'); }
-        'The resulting spec is invalid. Skipping Bad API Route Plugin',
+        [qr{Could not load REST API spec bundle: Invalid JSON specification},
+        qr{The resulting spec is invalid. Skipping Bad API Route Plugin},],
         'Bad plugins raise warning';
 
     my $routes = get_defined_routes($t);