From d449966b8c6d6c0b1998ecf6639f60e6ea46886d Mon Sep 17 00:00:00 2001
From: Tomas Cohen Arazi <tomascohen@theke.io>
Date: Tue, 21 Jan 2020 15:46:53 -0300
Subject: [PATCH] Bug 24356: prefetch_whitelist tests

This patch adds tests for the introduced methods.

To test:
1. Run the tests :-D
=> SUCCESS: They pass!
2. Sign off :-D
---
 t/db_dependent/Koha/Object.t  | 25 ++++++++++++++++++++++++-
 t/db_dependent/Koha/Objects.t | 28 ++++++++++++++++++++++++++--
 2 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/t/db_dependent/Koha/Object.t b/t/db_dependent/Koha/Object.t
index 6679bd5567..9e54675f6d 100755
--- a/t/db_dependent/Koha/Object.t
+++ b/t/db_dependent/Koha/Object.t
@@ -17,7 +17,7 @@
 
 use Modern::Perl;
 
-use Test::More tests => 18;
+use Test::More tests => 19;
 use Test::Exception;
 use Test::Warn;
 use DateTime;
@@ -795,3 +795,26 @@ subtest 'get_from_storage' => sub {
 
     $schema->storage->txn_rollback;
 };
+
+subtest 'prefetch_whitelist() tests' => sub {
+
+    plan tests => 2;
+
+    $schema->storage->txn_begin;
+
+    my $biblio = Koha::Biblio->new;
+
+    my $prefetch_whitelist = $biblio->prefetch_whitelist;
+
+    ok(
+        exists $prefetch_whitelist->{orders},
+        'Relationship matching method name is listed'
+    );
+    is(
+        $prefetch_whitelist->{orders},
+        'Koha::Acquisition::Order',
+        'Guessed the object class correctly'
+    );
+
+    $schema->storage->txn_rollback;
+};
diff --git a/t/db_dependent/Koha/Objects.t b/t/db_dependent/Koha/Objects.t
index 27dd4490e4..68292dd0db 100644
--- a/t/db_dependent/Koha/Objects.t
+++ b/t/db_dependent/Koha/Objects.t
@@ -19,12 +19,13 @@
 
 use Modern::Perl;
 
-use Test::More tests => 20;
+use Test::More tests => 21;
 use Test::Exception;
 use Test::Warn;
 
 use Koha::Authority::Types;
 use Koha::Cities;
+use Koha::Biblios;
 use Koha::IssuingRules;
 use Koha::Patron::Category;
 use Koha::Patron::Categories;
@@ -783,4 +784,27 @@ subtest "from_api_mapping() tests" => sub {
     );
 
     $schema->storage->txn_rollback;
-};
\ No newline at end of file
+};
+
+subtest 'prefetch_whitelist() tests' => sub {
+
+    plan tests => 2;
+
+    $schema->storage->txn_begin;
+
+    my $biblios = Koha::Biblios->new;
+
+    my $prefetch_whitelist = $biblios->prefetch_whitelist;
+
+    ok(
+        exists $prefetch_whitelist->{orders},
+        'Relationship matching method name is listed'
+    );
+    is(
+        $prefetch_whitelist->{orders},
+        'Koha::Acquisition::Order',
+        'Guessed the object class correctly'
+    );
+
+    $schema->storage->txn_rollback;
+};
-- 
2.17.1