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 <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Marcel de Rooy 2022-12-07 13:51:14 +00:00 committed by Tomas Cohen Arazi
parent 1d522cc246
commit d7c1d52051
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
1 changed files with 22 additions and 1 deletions

View File

@ -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;
};