From 5df190fa1f23c69a6874f24f42d3a06593a6999e Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 22 Nov 2021 16:30:13 +0000 Subject: [PATCH] [21.05.x] Bug 29495: Unit Tests Test plan 1. Run updated tests prior to applying new patches.. pass 2. Run updated tests after applying new patches.. pass Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/Koha/Checkouts/ReturnClaim.t | 33 +++++++++++++++------ 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/t/db_dependent/Koha/Checkouts/ReturnClaim.t b/t/db_dependent/Koha/Checkouts/ReturnClaim.t index cb31b10f1c..57a0514b4f 100755 --- a/t/db_dependent/Koha/Checkouts/ReturnClaim.t +++ b/t/db_dependent/Koha/Checkouts/ReturnClaim.t @@ -30,7 +30,7 @@ my $builder = t::lib::TestBuilder->new; subtest "store() tests" => sub { - plan tests => 11; + plan tests => 13; $schema->storage->txn_begin; @@ -59,23 +59,38 @@ subtest "store() tests" => sub { } )->store } 'Koha::Exceptions::Checkouts::ReturnClaims::NoCreatedBy', - 'Exception thrown correctly'; + 'Exception thrown if no created_by passed on creation'; - my $nullified_created_by = $builder->build_object( + my $old_checkout = $builder->build_object( { - class => 'Koha::Checkouts::ReturnClaims', + class => 'Koha::Old::Checkouts', value => { - created_by => undef + borrowernumber => $patron->borrowernumber, + itemnumber => $item->itemnumber, + branchcode => $patron->branchcode } } ); - is( $nullified_created_by->created_by, undef, 'Is undef' ); - ok( $nullified_created_by->in_storage, 'In storage' ); + my $nullable_created_by = Koha::Checkouts::ReturnClaim->new( + { + issue_id => $old_checkout->id, + itemnumber => $old_checkout->itemnumber, + borrowernumber => $old_checkout->borrowernumber, + notes => 'Some notes', + created_by => $librarian->borrowernumber + } + )->store; + is( $nullable_created_by->created_by, $librarian->borrowernumber, 'Claim created with created_by set' ); + ok( $nullable_created_by->in_storage, 'In storage' ); + + $nullable_created_by->created_by(undef)->store(); + is( $nullable_created_by->created_by, undef, 'Deletion was deleted' ); + ok( $nullable_created_by->in_storage, 'In storage' ); is( - ref($nullified_created_by->notes('Some other note')->store), + ref($nullable_created_by->notes('Some other note')->store), 'Koha::Checkouts::ReturnClaim', - 'No exception, store success' + 'Subsequent store succeeds after created_by has been unset' ); is( Koha::Checkouts::ReturnClaims->search({ issue_id => $checkout->id })->count, 0, 'No claims stored' ); -- 2.35.1