From 1db9119f97a80ba6c56d43b64cbd015b175cd07c Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 25 Feb 2020 12:15:21 +0100 Subject: [PATCH] Bug 24722: Add test Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- t/db_dependent/Koha/Holds.t | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Koha/Holds.t b/t/db_dependent/Koha/Holds.t index c8b967946d..055dd18d11 100644 --- a/t/db_dependent/Koha/Holds.t +++ b/t/db_dependent/Koha/Holds.t @@ -1,6 +1,6 @@ #!/usr/bin/perl -# Copyright 2017 Koha Development team +# Copyright 2020 Koha Development team # # This file is part of Koha # @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 1; +use Test::More tests => 2; use Test::Warn; use C4::Reserves; @@ -34,6 +34,30 @@ $schema->storage->txn_begin; my $builder = t::lib::TestBuilder->new; +subtest 'DB constraints' => sub { + plan tests => 1; + + my $patron = $builder->build_object({ class => 'Koha::Patrons' }); + my $item = $builder->build_sample_item; + my $hold_info = { + branchcode => $patron->branchcode, + borrowernumber => $patron->borrowernumber, + biblionumber => $item->biblionumber, + priority => 1, + title => "title for fee", + itemnumber => $item->itemnumber, + }; + + my $reserve_id = C4::Reserves::AddReserve($hold_info); + my $hold = Koha::Holds->find( $reserve_id ); + + warning_like { + eval { $hold->priority(undef)->store } + } + qr{.*DBD::mysql::st execute failed: Column 'priority' cannot be null.*}, + 'DBD should have raised an error about priority that cannot be null'; +}; + subtest 'cancel' => sub { plan tests => 12; my $biblioitem = $builder->build_object( { class => 'Koha::Biblioitems' } ); -- 2.11.0