From 5079f95bca0f1fb1d6f8b0f3a3cccb36c4b98315 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 Signed-off-by: David Nind Signed-off-by: Katrin Fischer --- 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 dc2232de2d..abe3d12a9f 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.11.0