Bug 40374: Remove warnings from Koha/Booking.t

t/db_dependent/Koha/Booking.t .. 1/2 DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Duplicate entry '7' for key 'PRIMARY' at /kohadevbox/koha/Koha/Object.pm line 174
DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Data truncated for column 'status' at row 1 at /kohadevbox/koha/Koha/Object.pm line 174

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit da423a717e)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Jonathan Druart 2025-07-15 11:43:33 +02:00 committed by Paul Derscheid
parent 4091d99c0c
commit 7566ed0d99
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
1 changed files with 23 additions and 6 deletions

View File

@ -20,7 +20,10 @@
use Modern::Perl;
use utf8;
use Test::More tests => 2;
use Test::More tests => 3;
use Test::NoWarnings;
use Test::Warn;
use Test::Exception;
@ -369,7 +372,7 @@ subtest 'store() tests' => sub {
};
subtest 'confirmation notice trigger' => sub {
plan tests => 2;
plan tests => 4;
# FIXME: This is a bandaid solution to prevent test failures when running
# the Koha_Main_My8 job because notices are not added at upgrade time.
@ -412,7 +415,16 @@ subtest 'store() tests' => sub {
)->count;
# Reuse previous booking to produce a clash
eval { $booking = Koha::Booking->new( $booking->unblessed )->store };
warning_like(
sub {
throws_ok {
Koha::Booking->new( $booking->unblessed )->store
}
'Koha::Exceptions::Object::DuplicateID',
'Exception is thrown correctly';
},
qr{Duplicate entry '(.*?)' for key '(.*\.?)PRIMARY'}
);
my $post_notices_count = Koha::Notice::Messages->search(
{
@ -612,12 +624,17 @@ subtest 'store() tests' => sub {
};
subtest 'status change exception' => sub {
plan tests => 2;
plan tests => 3;
$booking->discard_changes;
my $status = $booking->status;
throws_ok { $booking->update( { status => 'blah' } ) } 'Koha::Exceptions::Object::BadValue',
'Throws exception when passed booking status would fail enum constraint';
warning_like(
sub {
throws_ok { $booking->update( { status => 'blah' } ) } 'Koha::Exceptions::Object::BadValue',
'Throws exception when passed booking status would fail enum constraint';
},
qr{Data truncated for column 'status'}
);
# Status unchanged
$booking->discard_changes;