From 47da1131259d17514ed8522bcfc04b20f4b02355 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 29 Jul 2024 09:16:11 -0300 Subject: [PATCH] Bug 37510: Unit tests --- t/db_dependent/Koha/Object.t | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Object.t b/t/db_dependent/Koha/Object.t index b1c6bb51728..75a6fab9150 100755 --- a/t/db_dependent/Koha/Object.t +++ b/t/db_dependent/Koha/Object.t @@ -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,25 @@ subtest 'is_accessible() tests' => sub { $schema->storage->txn_rollback; }; + +subtest 'delete() tests' => sub { + + plan tests => 2; + + $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::Exception'; + + $biblio->metadata->set( { record_source_id => undef } )->store(); + + lives_ok { $rs->delete(); } + 'No exception thrown'; + + $schema->storage->txn_rollback; +}; -- 2.45.2