Bug 17647: Remove itemtype-related CancelReceipt.t warnings
authorTomas Cohen Arazi <tomascohen@theke.io>
Wed, 16 Nov 2016 19:44:44 +0000 (16:44 -0300)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 18 Nov 2016 14:01:06 +0000 (14:01 +0000)
This patch makes t/db_dependent/Acquisition/CancelReceipt.t create
good sample data for its tests. It does so by creating a random
itemtype.

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

Sponsored-by: ByWater Solutions
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
t/db_dependent/Acquisition/CancelReceipt.t

index 9f7ad19..288ff53 100644 (file)
@@ -1,8 +1,25 @@
 #!/usr/bin/perl
 
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
+
 use Modern::Perl;
 
 use Test::More tests => 12;
+use t::lib::TestBuilder;
+
 use C4::Context;
 use C4::Acquisition;
 use C4::Biblio;
@@ -21,6 +38,9 @@ $schema->storage->txn_begin();
 my $dbh = C4::Context->dbh;
 $dbh->{RaiseError} = 1;
 
+my $builder = t::lib::TestBuilder->new;
+my $itemtype = $builder->build({ source => 'Itemtype' })->{ itemtype };
+
 my $booksellerid1 = C4::Bookseller::AddBookseller(
     {
         name => "my vendor 1",
@@ -44,7 +64,7 @@ my $budgetid = C4::Budgets::AddBudget(
 my $budget = C4::Budgets::GetBudget( $budgetid );
 
 my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, '');
-my $itemnumber = AddItem({}, $biblionumber);
+my $itemnumber = AddItem( { itype => $itemtype }, $biblionumber );
 
 t::lib::Mocks::mock_preference('AcqCreateItem', 'receiving');
 my $order = Koha::Acquisition::Order->new(
@@ -71,8 +91,9 @@ CancelReceipt($ordernumber);
 
 is(scalar GetItemnumbersFromOrder($ordernumber), 0, "Create items on receiving: 0 item exist after cancelling a receipt");
 
-my $itemnumber1 = AddItem({}, $biblionumber);
-my $itemnumber2 = AddItem({}, $biblionumber);
+my $itemnumber1 = AddItem( { itype => $itemtype }, $biblionumber );
+my $itemnumber2 = AddItem( { itype => $itemtype }, $biblionumber );
+
 t::lib::Mocks::mock_preference('AcqCreateItem', 'ordering');
 t::lib::Mocks::mock_preference('AcqItemSetSubfieldsWhenReceiptIsCancelled', '7=9'); # notforloan is mapped with 952$7
 $order = Koha::Acquisition::Order->new(