Bug 17572: Remove itemtype-related warnings from issue.t

This patch makes t/db_dependent/Circulation/issue.t create
good sample data for its tests. It does so by creating a random
itemtype.

To test:
- Run
  $ prove t/db_dependent/Circulation/issue.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/issue.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>
This commit is contained in:
Tomas Cohen Arazi 2016-11-07 14:55:41 -03:00 committed by Kyle M Hall
parent 0550385730
commit 4bf2a1d81f
1 changed files with 28 additions and 13 deletions

View File

@ -17,18 +17,23 @@
use Modern::Perl;
use Koha::DateUtils;
use DateTime::Duration;
use Test::More tests => 32;
use t::lib::Mocks;
use t::lib::TestBuilder;
use C4::Biblio;
use C4::Members;
use C4::Circulation;
use C4::Items;
use C4::Context;
use C4::Items;
use C4::Members;
use C4::Reserves;
use Koha::Database;
use Koha::DateUtils;
use Koha::Library;
use Test::More tests => 32;
use DateTime::Duration;
BEGIN {
use_ok('C4::Circulation');
@ -50,10 +55,12 @@ can_ok(
)
);
#Start transaction
my $dbh = C4::Context->dbh;
$dbh->{RaiseError} = 1;
$dbh->{AutoCommit} = 0;
my $schema = Koha::Database->schema;
#Start transaction
$schema->storage->txn_begin;
my $builder = t::lib::TestBuilder->new();
$dbh->do(q|DELETE FROM issues|);
$dbh->do(q|DELETE FROM items|);
@ -63,7 +70,12 @@ $dbh->do(q|DELETE FROM categories|);
$dbh->do(q|DELETE FROM accountlines|);
$dbh->do(q|DELETE FROM issuingrules|);
#Add sample datas
# Generate sample datas
my $itemtype = $builder->build(
{ source => 'Itemtype',
value => { notforloan => undef, rentalcharge => 0 }
}
)->{itemtype};
#Add Dates
@ -158,7 +170,8 @@ my @sampleitem1 = C4::Items::AddItem(
homebranch => $samplebranch1->{branchcode},
holdingbranch => $samplebranch1->{branchcode},
issue => 1,
reserve => 1
reserve => 1,
itype => $itemtype
},
$biblionumber
);
@ -170,7 +183,8 @@ my @sampleitem2 = C4::Items::AddItem(
homebranch => $samplebranch2->{branchcode},
holdingbranch => $samplebranch2->{branchcode},
notforloan => 1,
issue => 1
issue => 1,
itype => $itemtype
},
$biblionumber
);
@ -369,7 +383,8 @@ my $itemnumber;
itemcallnumber => 'callnumber3',
homebranch => $samplebranch1->{branchcode},
holdingbranch => $samplebranch1->{branchcode},
notforloan => 1,
notforloan => 1,
itype => $itemtype
},
$biblionumber
);
@ -397,4 +412,4 @@ my $reserve = GetReserve( $reserve_id );
is( $reserve, undef, 'The reserve should have been correctly cancelled' );
#End transaction
$dbh->rollback;
$schema->storage->txn_rollback;