Bug 9761: Preliminary measures for adding a unit test
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Wed, 18 Sep 2013 14:12:09 +0000 (16:12 +0200)
committerGalen Charlton <gmc@esilibrary.com>
Wed, 25 Sep 2013 00:27:31 +0000 (00:27 +0000)
Optionally add some branches and categories that may not exist.

Test plan:
Run the test with or without CPL branch or S (staff) category.
Verify that the test does not fail.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
t/db_dependent/Reserves.t

index f511c41..7846fb3 100755 (executable)
@@ -22,6 +22,17 @@ $dbh->{AutoCommit} = 0;
 $dbh->{RaiseError} = 1;
 
 # Setup Test------------------------
+
+# Add branches if not existing
+foreach my $addbra ('CPL', 'FPL', 'RPL') {
+    $dbh->do("INSERT INTO branches (branchcode,branchname) VALUES (?,?)", undef, ($addbra,"$addbra branch")) unless GetBranchName($addbra);
+}
+
+# Add categories if not existing
+foreach my $addcat ('S', 'PT') {
+    $dbh->do("INSERT INTO categories (categorycode,hidelostitems,category_type) VALUES (?,?,?)",undef,($addcat, 0, $addcat eq 'S'? 'S': 'A')) unless GetBorrowercategory($addcat);
+}
+
 # Helper biblio.
 diag("\nCreating biblio instance for testing.");
 my $bib = MARC::Record->new();
@@ -32,6 +43,7 @@ $bib->append_fields(
 );
 my ($bibnum, $bibitemnum);
 ($bibnum, $title, $bibitemnum) = AddBiblio($bib, '');
+
 # Helper item for that biblio.
 diag("Creating item instance for testing.");
 my ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => 'CPL', holdingbranch => 'CPL' } , $bibnum);
@@ -199,3 +211,5 @@ is( $messages->{ResFound}->{borrowernumber},
 is( $messages->{ResFound}->{borrowernumber},
     $requesters{'RPL'},
     'for generous library, its items fill first hold request in line (bug 10272)');
+
+$dbh->rollback;