From 75510f2614b475e06eded36882a158ad9400ba5c Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 31 Jan 2020 00:27:05 -0300 Subject: [PATCH] Bug 24440: ->biblio tests Signed-off-by: Tomas Cohen Arazi Signed-off-by: David Nind --- t/db_dependent/Koha/Acquisition/Order.t | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Acquisition/Order.t b/t/db_dependent/Koha/Acquisition/Order.t index 6d2797bf35..aaa57910ac 100644 --- a/t/db_dependent/Koha/Acquisition/Order.t +++ b/t/db_dependent/Koha/Acquisition/Order.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 7; +use Test::More tests => 8; use t::lib::TestBuilder; use t::lib::Mocks; @@ -57,6 +57,32 @@ subtest 'basket() tests' => sub { $schema->storage->txn_rollback; }; +subtest 'biblio() tests' => sub { + + plan tests => 3; + + $schema->storage->txn_begin; + + my $order = $builder->build_object( + { + class => 'Koha::Acquisition::Orders', + value => { biblionumber => undef } + } + ); + + is( $order->biblio, undef, 'If no linked biblio, undef is returned' ); + + # Add and link a biblio to the order + my $biblio = $builder->build_sample_biblio(); + $order->set({ biblionumber => $biblio->biblionumber })->store->discard_changes; + + my $THE_biblio = $order->biblio; + is( ref($THE_biblio), 'Koha::Biblio', 'Returns a Koha::Biblio object' ); + is( $THE_biblio->biblionumber, $biblio->biblionumber, 'It is not cheating about the object' ); + + $schema->storage->txn_rollback; +}; + subtest 'store' => sub { plan tests => 1; -- 2.11.0