@@ -, +, @@ --- t/db_dependent/Koha/Acquisition/Order.t | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) --- a/t/db_dependent/Koha/Acquisition/Order.t +++ a/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; --