Bug 31889: (follow-up) Add test for explicit warning
authorTomas Cohen Arazi <tomascohen@theke.io>
Mon, 7 Nov 2022 11:29:15 +0000 (08:29 -0300)
committerTomas Cohen Arazi <tomascohen@theke.io>
Mon, 7 Nov 2022 11:29:22 +0000 (08:29 -0300)
On bug 29697, an explicit call to 'warn' was added, but no tests were
added for that behavior.

This patch adds that.

To test:

1. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Biblio/Metadata.t
=> FAIL: There's a warn, no tests for it :-(
2. Apply this patch
3. Repeat 1
=> SUCCESS: A new test was added, no more warns printed
4. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
t/db_dependent/Koha/Biblio/Metadata.t

index f64bfed..d6a5b8b 100755 (executable)
@@ -19,6 +19,7 @@ use Modern::Perl;
 
 use Test::More tests => 3;
 use Test::Exception;
+use Test::Warn;
 
 use t::lib::TestBuilder;
 use t::lib::Mocks;
@@ -35,7 +36,7 @@ my $builder = t::lib::TestBuilder->new;
 
 subtest 'record() tests' => sub {
 
-    plan tests => 8;
+    plan tests => 9;
 
     $schema->storage->txn_begin;
 
@@ -60,8 +61,11 @@ subtest 'record() tests' => sub {
         }
     );
 
-    throws_ok { $bad_data->record; }
-    'Koha::Exceptions::Metadata::Invalid', 'Exception thrown on bad record';
+    warning_like
+       { throws_ok { $bad_data->record; }
+        'Koha::Exceptions::Metadata::Invalid', 'Exception thrown on bad record'; }
+        qr/parser error : Start tag expected, '<' not found/,
+        'Warning thrown excplicitly';
 
     my $exception = $@;
     is( $exception->id,     $bad_data->id, 'id passed correctly to exception' );