From 2aee448d4669657f816c2c2e9b4e2e3d5409d02b Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 7 Nov 2024 11:51:24 +0000 Subject: [PATCH] Bug 38011: (QA follow-up) Additional unit tests Add an additional unit test for the default null on the new constraint. Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart --- t/db_dependent/Koha/Subscription.t | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/t/db_dependent/Koha/Subscription.t b/t/db_dependent/Koha/Subscription.t index 6765640d381..e32f871bf5c 100755 --- a/t/db_dependent/Koha/Subscription.t +++ b/t/db_dependent/Koha/Subscription.t @@ -80,17 +80,26 @@ subtest 'Notifications on new issues - add_subscriber|remove_subscriber|subscrib }; subtest 'Koha::Subscription->vendor' => sub { - plan tests => 2; - my $vendor = $builder->build( { source => 'Aqbookseller' } ); - my $subscription = $builder->build( + plan tests => 3; + my $vendor = $builder->build_object( { class => 'Koha::Acquisition::Booksellers' } ); + my $subscription = $builder->build_object( { - source => 'Subscription', - value => { aqbooksellerid => $vendor->{id} } + class => 'Koha::Subscriptions', + value => { aqbooksellerid => $vendor->id } } ); - my $object = Koha::Subscriptions->find( $subscription->{subscriptionid} ); - is( ref($object->vendor), 'Koha::Acquisition::Bookseller', 'Koha::Subscription->vendor should return a Koha::Acquisition::Bookseller' ); - is( $object->vendor->id, $subscription->{aqbooksellerid}, 'Koha::Subscription->vendor should return the correct vendor' ); + is( + ref( $subscription->vendor ), 'Koha::Acquisition::Bookseller', + 'Koha::Subscription->vendor should return a Koha::Acquisition::Bookseller' + ); + is( + $subscription->vendor->id, $subscription->aqbooksellerid, + 'Koha::Subscription->vendor should return the correct vendor' + ); + + $vendor->delete(); + $subscription->discard_changes; + is( $subscription->vendor, undef, 'Koha::Subscription->vendor should return undef if the vendor is deleted' ); }; subtest 'Koha::Subscription->frequency' => sub { -- 2.34.1