From 1ffc2d4501e89c56743a351e4725e45d3e2e57e9 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Wed, 30 Aug 2023 13:13:04 +0000 Subject: [PATCH] Bug 34609: Add tests Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi (cherry picked from commit eaa1a1d7e29d1421bf58f8215994e9ddfe8cdefa) Signed-off-by: Fridolin Somers (cherry picked from commit 315927af8bcc461693a5fe22b8f5cc44fc9f0e90) Signed-off-by: Matt Blenkinsop --- t/db_dependent/Koha/Old/Hold.t | 40 +++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Old/Hold.t b/t/db_dependent/Koha/Old/Hold.t index 91ed7a71c2..d62a3136fc 100755 --- a/t/db_dependent/Koha/Old/Hold.t +++ b/t/db_dependent/Koha/Old/Hold.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 1; +use Test::More tests => 2; use Test::Exception; use Koha::Database; @@ -80,3 +80,41 @@ subtest 'anonymize() tests' => sub { $schema->storage->txn_rollback; }; + +subtest 'biblio() tests' => sub { + + plan tests => 3; + + $schema->storage->txn_begin; + + my $hold_1 = $builder->build_object( + { + class => 'Koha::Old::Holds', + value => { biblionumber => undef } + } + ); + + is( $hold_1->biblio, undef, 'Old hold has no biblionumber, returns undef' ); + + my $hold_2 = $builder->build_object( + { + class => 'Koha::Old::Holds', + value => { biblionumber => '' } + } + ); + + is( $hold_1->biblio, undef, 'Old hold has empty biblionumber, returns undef' ); + + my $biblio = $builder->build_object( { class => 'Koha::Biblios' } ); + + my $hold_3 = $builder->build_object( + { + class => 'Koha::Old::Holds', + value => { biblionumber => $biblio->biblionumber } + } + ); + + is_deeply( $hold_3->biblio->unblessed, $biblio->unblessed, 'Old hold has a biblionumber, returns a biblio object' ); + + $schema->storage->txn_rollback; +}; -- 2.39.2