From aa8ed08a71ab3ef3338ac813a044bc0eaac73392 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 11 Apr 2019 09:51:20 -0400 Subject: [PATCH] Bug 22688: Unit tests --- t/db_dependent/Koha/Libraries.t | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Koha/Libraries.t b/t/db_dependent/Koha/Libraries.t index 5c356c1998..9cd78afa99 100644 --- a/t/db_dependent/Koha/Libraries.t +++ b/t/db_dependent/Koha/Libraries.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 7; +use Test::More tests => 8; use C4::Biblio; use C4::Context; @@ -35,6 +35,8 @@ use Koha::Database; use t::lib::Mocks; use t::lib::TestBuilder; +use_ok('Koha::Template::Plugin::Branches'); + my $schema = Koha::Database->new->schema; $schema->storage->txn_begin; @@ -115,7 +117,7 @@ subtest 'pickup_locations' => sub { my $itemtype = $biblio->itemtype; subtest 'UseBranchTransferLimits = OFF' => sub { - plan tests => 5; + plan tests => 10; t::lib::Mocks::mock_preference('UseBranchTransferLimits', 0); t::lib::Mocks::mock_preference('BranchTransferLimitsType', 'itemtype'); @@ -148,6 +150,28 @@ subtest 'pickup_locations' => sub { $pickup = Koha::Libraries->pickup_locations({ biblio => $bibnum }); is(@{$pickup}, $total_pickup, '...as well as when ' .'BranchTransferLimitsType = ccode'); + + # Test TT plugin + $pickup = Koha::Template::Plugin::Branches::pickup_locations({ biblio => $bibnum }); + is(C4::Context->preference('UseBranchTransferLimits'), 0, 'Given system ' + .'preference UseBranchTransferLimits is switched OFF,'); + is(@{$pickup}, $total_pickup, 'Then the total number of pickup locations ' + .'equal number of libraries with pickup_location => 1'); + + t::lib::Mocks::mock_preference('BranchTransferLimitsType', 'itemtype'); + t::lib::Mocks::mock_preference('item-level_itypes', 1); + $pickup = Koha::Template::Plugin::Branches::pickup_locations({ biblio => $bibnum }); + is(@{$pickup}, $total_pickup, '...when ' + .'BranchTransferLimitsType = itemtype and item-level_itypes = 1'); + t::lib::Mocks::mock_preference('item-level_itypes', 0); + $pickup = Koha::Template::Plugin::Branches::pickup_locations({ biblio => $bibnum }); + is(@{$pickup}, $total_pickup, '...as well as when ' + .'BranchTransferLimitsType = itemtype and item-level_itypes = 0'); + t::lib::Mocks::mock_preference('BranchTransferLimitsType', 'ccode'); + $pickup = Koha::Template::Plugin::Branches::pickup_locations({ biblio => $bibnum }); + is(@{$pickup}, $total_pickup, '...as well as when ' + .'BranchTransferLimitsType = ccode'); + t::lib::Mocks::mock_preference('item-level_itypes', 1); }; -- 2.20.1 (Apple Git-117)