Bug 37510: Unit tests

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 30a5baa706)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Tomas Cohen Arazi 2024-07-29 09:16:11 -03:00 committed by Lucas Gass
parent df9f28f54f
commit 7edc1c10a8
1 changed files with 28 additions and 1 deletions

View File

@ -17,7 +17,7 @@
use Modern::Perl;
use Test::More tests => 22;
use Test::More tests => 23;
use Test::Exception;
use Test::Warn;
@ -1237,3 +1237,30 @@ subtest 'is_accessible() tests' => sub {
$schema->storage->txn_rollback;
};
subtest 'delete() tests' => sub {
plan tests => 6;
$schema->storage->txn_begin;
my $rs = $builder->build_object( { class => 'Koha::RecordSources' } );
my $biblio = $builder->build_sample_biblio();
$biblio->metadata->set( { record_source_id => $rs->id } )->store();
throws_ok { $rs->delete(); }
'Koha::Exceptions::Object::FKConstraintDeletion';
is( $@->column, 'record_source_id' );
is( $@->constraint, 'record_metadata_fk_2' );
is( $@->fk, 'record_source_id' );
is( $@->table, 'biblio_metadata' );
$biblio->metadata->set( { record_source_id => undef } )->store();
lives_ok { $rs->delete(); }
'No exception thrown';
$schema->storage->txn_rollback;
};