From 28a9789bba244b7da684613ccb6f535d95c0a687 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi 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 | 26 +++++++++++++++++++++++++- t/db_dependent/Koha/Objects.t | 27 +++++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/Koha/Object.t b/t/db_dependent/Koha/Object.t index bcee55ca75..512b4f7815 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 => 17; +use Test::More tests => 18; use Test::Exception; use Test::Warn; use DateTime; @@ -26,6 +26,7 @@ use C4::Context; use C4::Circulation; # AddIssue use C4::Biblio; # AddBiblio +use Koha::Acquisition::Baskets; use Koha::Database; use Koha::DateUtils qw( dt_from_string ); use Koha::Libraries; @@ -737,3 +738,26 @@ subtest 'unblessed_all_relateds' => sub { $schema->storage->txn_rollback; }; + +subtest 'prefetch_whitelist() tests' => sub { + + plan tests => 2; + + $schema->storage->txn_begin; + + my $basket = Koha::Acquisition::Basket->new; + + my $prefetch_whitelist = $basket->prefetch_whitelist; + + ok( + exists $prefetch_whitelist->{basket_group}, + 'Relationship matching method name is listed' + ); + is( + $prefetch_whitelist->{basket_group}, + 'Koha::Acquisition::BasketGroup', + '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..566f1941fd 100644 --- a/t/db_dependent/Koha/Objects.t +++ b/t/db_dependent/Koha/Objects.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 20; +use Test::More tests => 21; use Test::Exception; use Test::Warn; @@ -783,4 +783,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 $baskets = Koha::Acquisition::Baskets->new; + + my $prefetch_whitelist = $baskets->prefetch_whitelist; + + ok( + exists $prefetch_whitelist->{basket_group}, + 'Relationship matching method name is listed' + ); + is( + $prefetch_whitelist->{basket_group}, + 'Koha::Acquisition::BasketGroup', + 'Guessed the object class correctly' + ); + + $schema->storage->txn_rollback; +}; -- 2.17.1