Bug 22008: Add tests for new constraints

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Martin Renvoize 2019-02-27 12:02:36 +00:00 committed by Nick Clemens
parent ce49552e6d
commit 4e067c83e4

View file

@ -274,17 +274,25 @@ subtest 'apply() tests' => sub {
$schema->storage->txn_rollback; $schema->storage->txn_rollback;
}; };
subtest 'Keep account info when a patron is deleted' => sub { subtest 'Keep account info when related patron, staff or item is deleted' => sub {
plan tests => 2; plan tests => 3;
$schema->storage->txn_begin; $schema->storage->txn_begin;
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
my $staff = $builder->build_object( { class => 'Koha::Patrons' } );
my $item = $builder->build_object({ class => 'Koha::Items' }); my $item = $builder->build_object({ class => 'Koha::Items' });
my $issue = $builder->build_object(
{
class => 'Koha::Checkout',
value => { itemnumber => $item->itemnumber }
}
);
my $line = Koha::Account::Line->new( my $line = Koha::Account::Line->new(
{ {
borrowernumber => $patron->borrowernumber, borrowernumber => $patron->borrowernumber,
manager_id => $staff->borrowernumber,
itemnumber => $item->itemnumber, itemnumber => $item->itemnumber,
accounttype => "F", accounttype => "F",
amount => 10, amount => 10,
@ -294,6 +302,10 @@ subtest 'Keep account info when a patron is deleted' => sub {
$line = $line->get_from_storage; $line = $line->get_from_storage;
is( $line->itemnumber, undef, "The account line should not be deleted when the related item is delete"); is( $line->itemnumber, undef, "The account line should not be deleted when the related item is delete");
$staff->delete;
$line = $line->get_from_storage;
is( $line->manager_id, undef, "The account line should not be deleted when the related staff is delete");
$patron->delete; $patron->delete;
$line = $line->get_from_storage; $line = $line->get_from_storage;
is( $line->borrowernumber, undef, "The account line should not be deleted when the related patron is delete"); is( $line->borrowernumber, undef, "The account line should not be deleted when the related patron is delete");