From 5145580973b9c91164127e39b293b8c696be7b7c Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 19 Sep 2019 10:50:46 -0300 Subject: [PATCH] Bug 23624: Unit tests Signed-off-by: Tomas Cohen Arazi Signed-off-by: Liz Rea Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/Reports/Guided.t | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Reports/Guided.t b/t/db_dependent/Reports/Guided.t index 9c87dcf531..a2c90eee2f 100644 --- a/t/db_dependent/Reports/Guided.t +++ b/t/db_dependent/Reports/Guided.t @@ -18,12 +18,13 @@ use Modern::Perl; -use Test::More tests => 10; +use Test::More tests => 11; use Test::Warn; use t::lib::TestBuilder; use C4::Context; use Koha::Database; +use Koha::Items; use Koha::Reports; use Koha::Notice::Messages; @@ -410,6 +411,28 @@ subtest 'Email report test' => sub { $schema->storage->txn_rollback; +subtest 'nb_rows() tests' => sub { + + plan tests => 1; + + $schema->storage->txn_begin; + + my $items_count = Koha::Items->search->count; + $builder->build_object({ class => 'Koha::Items' }); + $builder->build_object({ class => 'Koha::Items' }); + $items_count += 2; + + my $query = q{ + SELECT * FROM items xxx + }; + + my $nb_rows = nb_rows( $query ); + + is( $nb_rows, $items_count, 'nb_rows returns the right value' ); + + $schema->storage->txn_rollback; +}; + sub trim { my ($s) = @_; $s =~ s/^\s*(.*?)\s*$/$1/s; -- 2.23.0