From 081d8dfbea52c4ebc5646e0cd2bd7af39ba02d0c Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Wed, 18 Sep 2013 16:12:09 +0200 Subject: [PATCH] Bug 9761: Preliminary measures for adding a unit test Content-Type: text/plain; charset=utf-8 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. --- t/db_dependent/Reserves.t | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index f511c41..7846fb3 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -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; -- 1.7.7.6