From cf5e73033cdd7c41478320b4b213efd94cae626f Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 7 Nov 2022 08:29:15 -0300 Subject: [PATCH] Bug 31889: (follow-up) Add test for explicit warning 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 --- t/db_dependent/Koha/Biblio/Metadata.t | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/Koha/Biblio/Metadata.t b/t/db_dependent/Koha/Biblio/Metadata.t index f64bfedb552..d6a5b8b94e5 100755 --- a/t/db_dependent/Koha/Biblio/Metadata.t +++ b/t/db_dependent/Koha/Biblio/Metadata.t @@ -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' ); -- 2.34.1