From 70f893cfa1f23ac9403e4507954e94bde9a6f67c Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Wed, 7 Dec 2022 13:51:14 +0000 Subject: [PATCH] Bug 32417: Add unit test Test plan: Run t/db_dependent/Koha/Acquisition/Order.t This test should fail without the follow-up and pass with it. * not ok 53 - No croak on missing biblionumber when cancelling an order Signed-off-by: Marcel de Rooy Signed-off-by: Martin Renvoize Signed-off-by: David Nind --- t/db_dependent/Koha/Acquisition/Order.t | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Acquisition/Order.t b/t/db_dependent/Koha/Acquisition/Order.t index 26b6cd6856..bc5aa7ec32 100755 --- a/t/db_dependent/Koha/Acquisition/Order.t +++ b/t/db_dependent/Koha/Acquisition/Order.t @@ -624,7 +624,7 @@ subtest 'filter_by_current & filter_by_cancelled' => sub { subtest 'cancel() tests' => sub { - plan tests => 52; + plan tests => 54; $schema->storage->txn_begin; @@ -915,5 +915,26 @@ subtest 'cancel() tests' => sub { is( $messages[2]->message, 'error_delbiblio_items', 'Cannot delete on loan item' ); is( $messages[2]->payload->{biblio}->id, $biblio_id, 'The right biblio is attached' ); + # Call ->store with biblionumber NULL (as ->cancel does) + $item_1 = $builder->build_sample_item; + $biblio_id = $item_1->biblionumber; + $order= $builder->build_object({ + class => 'Koha::Acquisition::Orders', + value => { + orderstatus => 'new', + biblionumber => $biblio_id, + datecancellationprinted => undef, + cancellationreason => undef, + } + }); + my $columns = { + biblionumber => undef, + cancellationreason => $reason, + datecancellationprinted => \'NOW()', + orderstatus => 'cancelled', + }; + lives_ok { $order->set($columns)->store; } 'No croak on missing biblionumber when cancelling an order'; + throws_ok { $order->orderstatus('new')->store; } qr/Cannot insert order: Mandatory parameter biblionumber is missing/, 'Expected croak'; + $schema->storage->txn_rollback; }; -- 2.30.2