From 40f190305b0acfb122043024e43a5891984e004d Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 14 Jan 2020 10:09:12 -0300 Subject: [PATCH] Bug 24418: 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 91017eeaae..55c4cdee90 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 => 9; +use Test::More tests => 10; use C4::Biblio; use Koha::Database; @@ -456,3 +456,37 @@ subtest 'to_api() tests' => sub { $schema->storage->txn_rollback; }; + +subtest 'suggestions() tests' => sub { + + plan tests => 2; + + $schema->storage->txn_begin; + + my $biblio = $builder->build_sample_biblio(); + + my $suggestions = $biblio->suggestions->unblessed; + + is_deeply( + $biblio->suggestions->unblessed, + [], + '->suggestions returns an empty Koha::Suggestions resultset' + ); + + my $suggestion = $builder->build_object( + { + class => 'Koha::Suggestions', + value => { biblionumber => $biblio->biblionumber } + } + ); + + $suggestions = $biblio->suggestions->unblessed; + + is_deeply( + $biblio->suggestions->unblessed, + [ $suggestion->unblessed ], + '->suggestions returns the related Koha::Suggestion objects' + ); + + $schema->storage->txn_rollback; +}; -- 2.25.0