From 9d65f64c037273193a336f201f6d6257ac308590 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 15 Jan 2020 16:25:19 -0300 Subject: [PATCH] Bug 24430: Unit tests Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/Koha/Biblio.t | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t index e3a41399bb..34486075a7 100644 --- a/t/db_dependent/Koha/Biblio.t +++ b/t/db_dependent/Koha/Biblio.t @@ -17,10 +17,11 @@ use Modern::Perl; -use Test::More tests => 10; +use Test::More tests => 11; use C4::Biblio; use Koha::Database; +use Koha::Acquisition::Orders; use t::lib::TestBuilder; use t::lib::Mocks; @@ -490,3 +491,36 @@ subtest 'suggestions() tests' => sub { $schema->storage->txn_rollback; }; + +subtest 'orders() and orders_count() tests' => sub { + + plan tests => 4; + + $schema->storage->txn_begin; + + my $biblio = $builder->build_sample_biblio(); + + my $orders = $biblio->orders; + my $orders_count = $biblio->orders_count; + + is( ref($orders), 'Koha::Acquisition::Orders', 'Result type is correct' ); + is( $orders->count, $orders_count, '->orders_count returns the count for the resultset' ); + + # Add a couple orders + foreach (1..2) { + $builder->build_object( + { + class => 'Koha::Acquisition::Orders', + value => { biblionumber => $biblio->biblionumber } + } + ); + } + + $orders = $biblio->orders; + $orders_count = $biblio->orders_count; + + is( ref($orders), 'Koha::Acquisition::Orders', 'Result type is correct' ); + is( $orders->count, $orders_count, '->orders_count returns the count for the resultset' ); + + $schema->storage->txn_rollback; +}; -- 2.25.0