From a9d8245943dedbe6a56e8bc62ac7d91e3adca3e8 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 5 May 2025 09:14:35 -0300 Subject: [PATCH 1/2] Bug 39832: Unit tests Signed-off-by: Roman Dolny Signed-off-by: Emmi Takkinen --- 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 71a392be9d..4e3ed58ddb 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.34.1