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 <tomascohen@theke.io>

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
This commit is contained in:
Martin Renvoize 2021-11-22 16:30:13 +00:00 committed by Andrew Fuerste-Henry
parent 237fca4402
commit a052d6752c
1 changed files with 24 additions and 9 deletions

View File

@ -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' );