Bug 17592: Remove itemtype-related maxsuspensiondays.t warnings
authorTomas Cohen Arazi <tomascohen@theke.io>
Tue, 8 Nov 2016 19:28:07 +0000 (16:28 -0300)
committerKyle M Hall <kyle@bywatersolutions.com>
Sat, 12 Nov 2016 02:37:08 +0000 (02:37 +0000)
This patch makes t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t create
good sample data for its tests. It does so by creating a random
itemtype.

To test:
- Run
  $ prove t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t
=> FAIL: lots of warnings about "item-level_itypes set but no itemtype
set for item"
- Apply the patch
- Run:
  $ prove t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t
=> SUCCESS: Tests are green, and no warnings.
- Sign off :-D

Sponsored-by: ByWater Solutions
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
t/db_dependent/Circulation/IssuingRules/maxsuspensiondays.t

index 78e268d..9695740 100644 (file)
@@ -22,11 +22,9 @@ my $builder = t::lib::TestBuilder->new;
 my $dbh = C4::Context->dbh;
 $dbh->{RaiseError} = 1;
 
-my $library = $builder->build({
-    source => 'Branch',
-});
+my $branchcode = $builder->build({ source => 'Branch' })->{branchcode};
+my $itemtype   = $builder->build({ source => 'Itemtype' })->{itemtype};
 
-my $branchcode = $library->{branchcode};
 local $SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /redefined/ };
 my $userenv->{branch} = $branchcode;
 *C4::Context::userenv = \&Mock_userenv;
@@ -62,6 +60,7 @@ my (undef, undef, $itemnumber) = AddItem({
         homebranch => $branchcode,
         holdingbranch => $branchcode,
         barcode => $barcode,
+        itype => $itemtype
     } , $biblionumber);
 
 # clear any holidays to avoid throwing off the suspension day
@@ -102,6 +101,7 @@ is(
 );
 DelDebarment( $debarments->[0]->{borrower_debarment_id} );
 
+$schema->storage->txn_rollback;
 
 # C4::Context->userenv
 sub Mock_userenv {