From e022f334c2104a65a0064b76affc421d72d5db03 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 15 Jul 2025 12:26:28 +0200 Subject: [PATCH] Bug 40378: Remove warnings from api/v1/biblios.t t/db_dependent/api/v1/biblios.t .. 12/15 DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Duplicate entry 'cZt7U7mP0KD' for key 'itembarcodeidx' at /kohadevbox/koha/Koha/Obj ect.pm line 174 t/db_dependent/api/v1/biblios.t .. 13/15 DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Duplicate entry 'N44vCoe4tX41' for key 'itembarcodeidx' at /kohadevbox/koha/Koha/Ob ject.pm line 174 Signed-off-by: David Nind Signed-off-by: Marcel de Rooy Signed-off-by: Lucas Gass (cherry picked from commit 71eb056850c882518d402c28701f0e8dbf74ce84) Signed-off-by: Paul Derscheid (cherry picked from commit 3b4e9dc5cbab8a074def23479aae7c94e411a7ce) Signed-off-by: Fridolin Somers --- t/db_dependent/api/v1/biblios.t | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/t/db_dependent/api/v1/biblios.t b/t/db_dependent/api/v1/biblios.t index c42d9c1336..614b4072d1 100755 --- a/t/db_dependent/api/v1/biblios.t +++ b/t/db_dependent/api/v1/biblios.t @@ -20,7 +20,8 @@ use Modern::Perl; use utf8; use Encode; -use Test::More tests => 15; +use Test::More tests => 16; +use Test::NoWarnings; use Test::MockModule; use Test::Mojo; use Test::Warn; @@ -1909,7 +1910,7 @@ subtest 'list() tests' => sub { subtest 'add_item() tests' => sub { - plan tests => 8; + plan tests => 10; $schema->storage->txn_begin; @@ -1959,17 +1960,20 @@ subtest 'add_item() tests' => sub { my $item = $builder->build_sample_item(); - $t->post_ok( - "//$userid:$password@/api/v1/biblios/$biblio_id/items" => json => { - external_id => $item->barcode, - } - )->status_is( 409, 'Duplicate barcode' ); + warnings_like { + $t->post_ok( + "//$userid:$password@/api/v1/biblios/$biblio_id/items" => json => { + external_id => $item->barcode, + } + )->status_is( 409, 'Duplicate barcode' )->json_is( "/error" => "Duplicate barcode." ); + } + qr{DBD::mysql::st execute failed: Duplicate entry '(.*?)' for key '(.*\.?)itembarcodeidx'}; $schema->storage->txn_rollback; }; subtest 'update_item() tests' => sub { - plan tests => 7; + plan tests => 9; $schema->storage->txn_begin; @@ -2012,10 +2016,14 @@ subtest 'update_item() tests' => sub { my $other_item = $builder->build_sample_item(); - $t->put_ok("//$userid:$password@/api/v1/biblios/$biblio_id/items/$item_id" => json => { - external_id => $other_item->barcode, - }) - ->status_is(409, 'Barcode not unique'); + warnings_like { + $t->put_ok( + "//$userid:$password@/api/v1/biblios/$biblio_id/items/$item_id" => json => { + external_id => $other_item->barcode, + } + )->status_is( 409, 'Barcode not unique' )->json_is( "/error" => "Duplicate barcode." ); + } + qr{DBD::mysql::st execute failed: Duplicate entry '(.*?)' for key '(.*\.?)itembarcodeidx'}; $t->put_ok("//$userid:$password@/api/v1/biblios/$biblio_id/items/$item_id" => json => { replacement_price => 30,