This patch adds the resdate and expdate argument to the AddReserve test. I also adjusted it to create a bilio, and item for that biblio and delete them at the end of the test, so its not dependent on external test data.
It gets rid of Illegal metric data warning from misaligned arguments. TestPlan: koha@biblio:~/kohaclone$ prove t/db_dependent/Reserves.t t/db_dependent/Reserves.t .. 1/4 # # Creating biblio instance for testing. # Creating item instance for testing. # Deleting item testing instance. # Deleting biblio testing instance. t/db_dependent/Reserves.t .. ok All tests successful. Files=1, Tests=4, 2 wallclock secs ( 0.03 usr 0.01 sys + 0.59 cusr 0.04 csys = 0.67 CPU) Result: PASS
>From ac4fd07c791bda6914f9fd241832988fa4df8529 Mon Sep 17 00:00:00 2001 From: wajasu <[email protected]> Date: Wed, 5 Sep 2012 11:35:42 -0500 Subject: [PATCH] adjust Reserves.t test for resdate and expdate and test setup/teardown --- t/db_dependent/Reserves.t | 59 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index ca4d42e..d3428b3 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -5,6 +5,9 @@ use warnings; use C4::Branch; use Test::More tests => 4; +use MARC::Record; +use C4::Biblio; +use C4::Items; BEGIN { use FindBin; @@ -12,6 +15,20 @@ BEGIN { use_ok('C4::Reserves'); } +# Setup Test------------------------ +# Helper biblio. +diag("\nCreating biblio instance for testing."); +my ($bibnum, $title, $bibitemnum) = create_helper_biblio(); + +# Helper item for that biblio. +diag("Creating item instance for testing."); +my ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => 'CPL', holdingbranch => 'CPL' } , $bibnum); + +# Modify item; setting barcode. +my $testbarcode = '97531'; +ModItem({ barcode => $testbarcode }, $bibnum, $itemnumber); + +# Get a borrower my $dbh = C4::Context->dbh; my $query = qq/SELECT borrowernumber FROM borrowers @@ -20,27 +37,16 @@ my $sth = $dbh->prepare($query); $sth->execute; my $borrower = $sth->fetchrow_hashref; -$query = qq/SELECT biblionumber, title, itemnumber, barcode - FROM biblio - LEFT JOIN items USING (biblionumber) - WHERE barcode <> "" - AND barcode IS NOT NULL - LIMIT 1/; -$sth = $dbh->prepare($query); -$sth->execute; -my $biblio = $sth->fetchrow_hashref; - - my $borrowernumber = $borrower->{'borrowernumber'}; -my $biblionumber = $biblio->{'biblionumber'}; -my $itemnumber = $biblio->{'itemnumber'}; -my $barcode = $biblio->{'barcode'}; +my $biblionumber = $bibnum; +my $barcode = $testbarcode; my $constraint = 'a'; my $bibitems = ''; my $priority = '1'; +my $resdate = undef; +my $expdate = undef; my $notes = ''; -my $title = $biblio->{'title'}; my $checkitem = undef; my $found = undef; @@ -48,7 +54,7 @@ my @branches = GetBranchesLoop(); my $branch = $branches[0][0]{value}; AddReserve($branch, $borrowernumber, $biblionumber, - $constraint, $bibitems, $priority, $notes, + $constraint, $bibitems, $priority, $resdate, $expdate, $notes, $title, $checkitem, $found); my ($status, $reserve, $all_reserves) = CheckReserves($itemnumber, $barcode); @@ -60,3 +66,24 @@ ok($status eq "Reserved", "CheckReserves Test 2"); ($status, $reserve, $all_reserves) = CheckReserves(undef, $barcode); ok($status eq "Reserved", "CheckReserves Test 3"); + +# Teardown Test--------------------- +# Delete item. +diag("Deleting item testing instance."); +DelItem($dbh, $bibnum, $itemnumber); + +# Delete helper Biblio. +diag("Deleting biblio testing instance."); +DelBiblio($bibnum); + +# Helper method to set up a Biblio. +sub create_helper_biblio { + my $bib = MARC::Record->new(); + my $title = 'Silence in the library'; + $bib->append_fields( + MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), + MARC::Field->new('245', ' ', ' ', a => $title), + ); + return ($bibnum, $title, $bibitemnum) = AddBiblio($bib, ''); +} + -- 1.7.11.4
_______________________________________________ Koha-patches mailing list [email protected] http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-patches website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
