Bugzilla – Attachment 19185 Details for
Bug 10289
UT: Reserves.t needs to create its own data
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10289: UT: Reserves.t needs to create its own data
Bug-10289-UT-Reservest-needs-to-create-its-own-dat.patch (text/plain), 4.26 KB, created by
Kyle M Hall (khall)
on 2013-06-21 13:09:33 UTC
(
hide
)
Description:
Bug 10289: UT: Reserves.t needs to create its own data
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2013-06-21 13:09:33 UTC
Size:
4.26 KB
patch
obsolete
>From f812aeec7dd437ef683fd3b525895dbe6058ea9b Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Mon, 20 May 2013 16:37:10 +0200 >Subject: [PATCH] Bug 10289: UT: Reserves.t needs to create its own data > >Try before the patch: >prove t/db_dependent/Reserves.t > >And after, it should produce: > 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. > # Deleting borrower. > t/db_dependent/Reserves.t .. ok > All tests successful. > Files=1, Tests=4, 1 wallclock secs ( 0.02 usr 0.01 sys + 0.39 cusr 0.02 csys = 0.44 CPU) > Result: PASS > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/db_dependent/Reserves.t | 64 ++++++++++++++++++++++---------------------- > 1 files changed, 32 insertions(+), 32 deletions(-) > >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index 1e20318..2033620 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -1,25 +1,30 @@ > #!/usr/bin/perl > >-use strict; >-use warnings; >-use C4::Branch; >+use Modern::Perl; > > use Test::More tests => 4; > use MARC::Record; >+ >+use C4::Branch; > use C4::Biblio; > use C4::Items; >+use C4::Members; > > BEGIN { >- use FindBin; >- use lib $FindBin::Bin; >- use_ok('C4::Reserves'); >+ use_ok('C4::Reserves'); > } > > # Setup Test------------------------ > # Helper biblio. > diag("\nCreating biblio instance for testing."); >-my ($bibnum, $title, $bibitemnum) = 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), >+); >+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); >@@ -28,16 +33,16 @@ my ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => 'CPL' > my $testbarcode = '97531'; > ModItem({ barcode => $testbarcode }, $bibnum, $itemnumber); > >-# Get a borrower >-my $dbh = C4::Context->dbh; >-my $query = qq/SELECT borrowernumber >- FROM borrowers >- LIMIT 1/; >-my $sth = $dbh->prepare($query); >-$sth->execute; >-my $borrower = $sth->fetchrow_hashref; >- >-my $borrowernumber = $borrower->{'borrowernumber'}; >+# Create a borrower >+my %data = ( >+ cardnumber => 'CARDNUMBER42', >+ firstname => 'my firstname', >+ surname => 'my surname', >+ categorycode => 'S', >+ branchcode => 'CPL', >+); >+my $borrowernumber = AddMember(%data); >+my $borrower = GetMember( borrowernumber => $borrowernumber ); > my $biblionumber = $bibnum; > my $barcode = $testbarcode; > >@@ -56,33 +61,28 @@ my $branch = $branches[0][0]{value}; > AddReserve($branch, $borrowernumber, $biblionumber, > $constraint, $bibitems, $priority, $resdate, $expdate, $notes, > $title, $checkitem, $found); >- >+ > my ($status, $reserve, $all_reserves) = CheckReserves($itemnumber, $barcode); >-ok($status eq "Reserved", "CheckReserves Test 1"); >+ >+is($status, "Reserved", "CheckReserves Test 1"); > > ($status, $reserve, $all_reserves) = CheckReserves($itemnumber); >-ok($status eq "Reserved", "CheckReserves Test 2"); >+is($status, "Reserved", "CheckReserves Test 2"); > > ($status, $reserve, $all_reserves) = CheckReserves(undef, $barcode); >-ok($status eq "Reserved", "CheckReserves Test 3"); >+is($status, "Reserved", "CheckReserves Test 3"); > > > # Teardown Test--------------------- > # Delete item. > diag("Deleting item testing instance."); >+my $dbh = C4::Context->dbh; > 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, ''); >-} >+# Delete borrower >+diag("Deleting borrower."); >+DelMember($borrowernumber); >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 10289
:
18250
|
18659
|
18660
|
19185
|
19448