From a52767dc39ca5a76aae9ff446c96d363a4d9dd62 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 23 Sep 2020 15:56:32 -0300 Subject: [PATCH] Bug 26524: Unit tests --- t/db_dependent/Koha/Acquisition/Basket.t | 31 +++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Acquisition/Basket.t b/t/db_dependent/Koha/Acquisition/Basket.t index dc2232de2db..abe3d12a9f3 100755 --- a/t/db_dependent/Koha/Acquisition/Basket.t +++ b/t/db_dependent/Koha/Acquisition/Basket.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 9; +use Test::More tests => 10; use t::lib::TestBuilder; use t::lib::Mocks; @@ -271,3 +271,32 @@ subtest 'authorizer' => sub { $schema->storage->txn_rollback; }; + +subtest 'orders' => sub { + + plan tests => 4; + + $schema->storage->txn_begin; + + my $basket = $builder->build_object( + { + class => 'Koha::Acquisition::Baskets' + } + ); + + my $orders = $basket->orders; + is( ref($orders), 'Koha::Acquisition::Orders', 'Type is correct with no attached orders' ); + is( $orders->count, 0, 'No orders attached, count 0' ); + + my @actual_orders; + + for ( 1..10 ) { + push @actual_orders, $builder->build_object({ class => 'Koha::Acquisition::Orders', value => { basketno => $basket->id } }); + } + + $orders = $basket->orders; + is( ref($orders), 'Koha::Acquisition::Orders', 'Type is correct with no attached orders' ); + is( $orders->count, 10, '10 orders attached, count 10' ); + + $schema->storage->txn_rollback; +}; -- 2.28.0