From 816d946cf21a17fa0d2627ac509e2f42d632b8a0 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 5 May 2025 09:14:35 -0300 Subject: [PATCH] Bug 39832: Unit tests --- t/db_dependent/Koha/Acquisition/Basket.t | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Acquisition/Basket.t b/t/db_dependent/Koha/Acquisition/Basket.t index 71a392be9d3..4e3ed58ddbb 100755 --- a/t/db_dependent/Koha/Acquisition/Basket.t +++ b/t/db_dependent/Koha/Acquisition/Basket.t @@ -20,7 +20,7 @@ use Modern::Perl; use Test::NoWarnings; -use Test::More tests => 14; +use Test::More tests => 15; use Test::Exception; use t::lib::TestBuilder; @@ -445,3 +445,22 @@ subtest 'close() tests' => sub { $schema->storage->txn_rollback; }; + +subtest 'vendor() tests' => sub { + + plan tests => 2; + + $schema->storage->txn_begin; + + my $basket = $builder->build_object( { class => 'Koha::Acquisition::Baskets' } ); + my $vendor = $basket->vendor; + is( ref($vendor), 'Koha::Acquisition::Bookseller', 'Right object type' ); + my $other_vendor = $builder->build_object( { class => 'Koha::Acquisition::Booksellers' } ); + + # change the vendor + $basket->set( { booksellerid => $other_vendor->id } )->store()->discard_changes(); + + is( $basket->vendor->id, $other_vendor->id, 'Method returns the new vendor' ); + + $schema->storage->txn_rollback; +}; -- 2.49.0