[Koha-patches] [PATCH] bug_11213: Use branch codes from the database rather than hardcoded CPL and MPL

Srdjan srdjan at catalyst.net.nz
Tue Apr 1 07:48:35 CEST 2014


---
 t/db_dependent/Items.t | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t
index 5ec8d34..bec6d9d 100755
--- a/t/db_dependent/Items.t
+++ b/t/db_dependent/Items.t
@@ -20,6 +20,7 @@ use Modern::Perl;
 
 use MARC::Record;
 use C4::Biblio;
+use C4::Branch;
 
 use Test::More tests => 3;
 
@@ -28,6 +29,8 @@ BEGIN {
 }
 
 my $dbh = C4::Context->dbh;
+my $branches = GetBranches;
+my ($branch1, $branch2) = keys %$branches;
 
 subtest 'General Add, Get and Del tests' => sub {
 
@@ -42,7 +45,7 @@ subtest 'General Add, Get and Del tests' => sub {
     my ($bibnum, $bibitemnum) = get_biblio();
 
     # Add an item.
-    my ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => 'CPL', holdingbranch => 'CPL' } , $bibnum);
+    my ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $branch1, holdingbranch => $branch1 } , $bibnum);
     cmp_ok($item_bibnum, '==', $bibnum, "New item is linked to correct biblionumber.");
     cmp_ok($item_bibitemnum, '==', $bibitemnum, "New item is linked to correct biblioitemnumber.");
 
@@ -79,14 +82,14 @@ subtest 'GetHiddenItemnumbers tests' => sub {
 
     # Add two items
     my ($item1_bibnum, $item1_bibitemnum, $item1_itemnumber) = AddItem(
-            { homebranch => 'CPL',
-              holdingbranch => 'CPL',
+            { homebranch => $branch1,
+              holdingbranch => $branch1,
               withdrawn => 1 },
             $biblionumber
     );
     my ($item2_bibnum, $item2_bibitemnum, $item2_itemnumber) = AddItem(
-            { homebranch => 'MPL',
-              holdingbranch => 'MPL',
+            { homebranch => $branch2,
+              holdingbranch => $branch2,
               withdrawn => 0 },
             $biblionumber
     );
@@ -127,7 +130,7 @@ subtest 'GetHiddenItemnumbers tests' => sub {
     # Two variables, a value each
     $opachiddenitems = "
         withdrawn: [1]
-        homebranch: [MPL]
+        homebranch: [$branch2]
     ";
     C4::Context->set_preference( 'OpacHiddenItems', $opachiddenitems );
     @hidden = GetHiddenItemnumbers( @items );
-- 
1.8.3.2


More information about the Koha-patches mailing list