From f4297e79bdd24985e7b317472f8daf5296b9b34e Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Sat, 20 Apr 2019 09:47:43 -0300 Subject: [PATCH] Bug 22701: Unit tests for Koha::Biblio->items This patch adds tests fr the current items() implementation. The idea is to verify no behaviour change takes place after we make it us _new_from_dbic instead of calling Koha::Items->search. To test: - Run: $ kshell k$ prove t/db_dependent/Koha/Biblio.t => SUCCESS: Tests pass! - Sign off :-D Signed-off-by: Martin Renvoize --- t/db_dependent/Koha/Biblio.t | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t index 72c06e04f9..1e050ca68d 100644 --- a/t/db_dependent/Koha/Biblio.t +++ b/t/db_dependent/Koha/Biblio.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 4; +use Test::More tests => 5; use t::lib::TestBuilder; @@ -86,3 +86,24 @@ subtest 'hidden_in_opac() tests' => sub { $schema->storage->txn_rollback; }; + +subtest 'items() tests' => sub { + + plan tests => 3; + + $schema->storage->txn_begin; + + my $biblio = $builder->build_sample_biblio(); + my $item_1 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); + my $item_2 = $builder->build_sample_item({ biblionumber => $biblio->biblionumber }); + + my $items = $biblio->items; + is( ref($items), 'Koha::Items', 'Returns a Koha::Items resultset' ); + is( $items->count, 2, 'Two items in resultset' ); + + my @items = $biblio->items; + is( scalar @items, 2, 'Same result, but in list context' ); + + $schema->storage->txn_rollback; + +}; -- 2.20.1