Bugzilla – Attachment 50009 Details for
Bug 16216
Circulation_Branch.t doesn't set itemtype for test data
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 16216: Circulation_Branch.t doesn't set itemtype for test data
PASSED-QA-Bug-16216-CirculationBrancht-doesnt-set-.patch (text/plain), 9.30 KB, created by
Katrin Fischer
on 2016-04-07 05:41:17 UTC
(
hide
)
Description:
[PASSED QA] Bug 16216: Circulation_Branch.t doesn't set itemtype for test data
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2016-04-07 05:41:17 UTC
Size:
9.30 KB
patch
obsolete
>From 75a8cd44ffcd8888c8af0996e01e132a65bce9b1 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@unc.edu.ar> >Date: Wed, 6 Apr 2016 12:44:25 -0300 >Subject: [PATCH] [PASSED QA] Bug 16216: Circulation_Branch.t doesn't set > itemtype for test data > >This patch makes the tests create better data for them: >- Run > $ prove t/db_dependent/Circulation_Branch.t >=> FAIL: Warnings raised >- Apply the patch >- Run > $ prove t/db_dependent/Circulation_Branch.t >=> SUCCESS: No warnings raised >- Sign off > >Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com> >Test pass successful > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > t/db_dependent/Circulation_Branch.t | 191 ++++++++++++------------------------ > 1 file changed, 62 insertions(+), 129 deletions(-) > >diff --git a/t/db_dependent/Circulation_Branch.t b/t/db_dependent/Circulation_Branch.t >index 05ee584..d2f4583 100644 >--- a/t/db_dependent/Circulation_Branch.t >+++ b/t/db_dependent/Circulation_Branch.t >@@ -1,15 +1,31 @@ > #!/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 t::lib::Mocks; >+ > use C4::Biblio; > use C4::Members; > use C4::Circulation; > use C4::Items; > use C4::Context; >-use Koha::Library; > > use Test::More tests => 14; >+use t::lib::Mocks; >+use t::lib::TestBuilder; > > BEGIN { > use_ok('C4::Circulation'); >@@ -24,10 +40,9 @@ can_ok( 'C4::Circulation', qw( > ) > ); > >-#Start transaction >+my $schema = Koha::Database->schema; >+$schema->storage->txn_begin; > my $dbh = C4::Context->dbh; >-$dbh->{RaiseError} = 1; >-$dbh->{AutoCommit} = 0; > > $dbh->do(q|DELETE FROM issues|); > $dbh->do(q|DELETE FROM items|); >@@ -42,125 +57,40 @@ $dbh->do(q|DELETE FROM default_branch_circ_rules|); > $dbh->do(q|DELETE FROM default_circ_rules|); > $dbh->do(q|DELETE FROM default_branch_item_rules|); > >-#Add branch and category >-my $samplebranch1 = { >- branchcode => 'SAB1', >- branchname => 'Sample Branch', >- branchaddress1 => 'sample adr1', >- branchaddress2 => 'sample adr2', >- branchaddress3 => 'sample adr3', >- branchzip => 'sample zip', >- branchcity => 'sample city', >- branchstate => 'sample state', >- branchcountry => 'sample country', >- branchphone => 'sample phone', >- branchfax => 'sample fax', >- branchemail => 'sample email', >- branchurl => 'sample url', >- branchip => 'sample ip', >- branchprinter => undef, >- opac_info => 'sample opac', >-}; >-my $samplebranch2 = { >- branchcode => 'SAB2', >- branchname => 'Sample Branch2', >- branchaddress1 => 'sample adr1_2', >- branchaddress2 => 'sample adr2_2', >- branchaddress3 => 'sample adr3_2', >- branchzip => 'sample zip2', >- branchcity => 'sample city2', >- branchstate => 'sample state2', >- branchcountry => 'sample country2', >- branchphone => 'sample phone2', >- branchfax => 'sample fax2', >- branchemail => 'sample email2', >- branchurl => 'sample url2', >- branchip => 'sample ip2', >- branchprinter => undef, >- opac_info => 'sample opac2', >-}; >-Koha::Library->new($samplebranch1)->store; >-Koha::Library->new($samplebranch2)->store; >- >-my $samplecat = { >- categorycode => 'CAT1', >- description => 'Description1', >- enrolmentperiod => 'Null', >- enrolmentperioddate => 'Null', >- dateofbirthrequired => 'Null', >- finetype => 'Null', >- bulk => 'Null', >- enrolmentfee => 'Null', >- overduenoticerequired => 'Null', >- issuelimit => 'Null', >- reservefee => 'Null', >- hidelostitems => 0, >- category_type => 'Null' >-}; >-my $query = >-"INSERT INTO categories (categorycode, >- description, >- enrolmentperiod, >- enrolmentperioddate, >- dateofbirthrequired , >- finetype, >- bulk, >- enrolmentfee, >- overduenoticerequired, >- issuelimit, >- reservefee, >- hidelostitems, >- category_type >- ) >-VALUES( ?,?,?,?,?,?,?,?,?,?,?,?,?)"; >-$dbh->do( >- $query, {}, >- $samplecat->{categorycode}, $samplecat->{description}, >- $samplecat->{enrolmentperiod}, $samplecat->{enrolmentperioddate}, >- $samplecat->{dateofbirthrequired}, $samplecat->{finetype}, >- $samplecat->{bulk}, $samplecat->{enrolmentfee}, >- $samplecat->{overduenoticerequired}, $samplecat->{issuelimit}, >- $samplecat->{reservefee}, $samplecat->{hidelostitems}, >- $samplecat->{category_type} >-); >+my $builder = t::lib::TestBuilder->new(); > >-#Add itemtypes >-my $sampleitemtype1 = { >- itemtype => 'BOOK', >- description => 'BookDescription', >- rentalcharge => '10.0', >- notforloan => 1, >- imageurl => 'Null', >- summary => 'BookSummary' >-}; >-my $sampleitemtype2 = { >- itemtype => 'DVD', >- description => 'DvdDescription', >- rentalcharge => '5.0', >- notforloan => 0, >- imageurl => 'Null', >- summary => 'DvdSummary' >-}; >-$query = >-"INSERT INTO itemtypes (itemtype, >- description, >- rentalcharge, >- notforloan, >- imageurl, >- summary >- ) >- VALUES( ?,?,?,?,?,?)"; >-my $sth = $dbh->prepare($query); >-$sth->execute( >- $sampleitemtype1->{itemtype}, $sampleitemtype1->{description}, >- $sampleitemtype1->{rentalcharge}, $sampleitemtype1->{notforloan}, >- $sampleitemtype1->{imageurl}, $sampleitemtype1->{summary} >-); >-$sth->execute( >- $sampleitemtype2->{itemtype}, $sampleitemtype2->{description}, >- $sampleitemtype2->{rentalcharge}, $sampleitemtype2->{notforloan}, >- $sampleitemtype2->{imageurl}, $sampleitemtype2->{summary} >-); >+# Add branch >+my $samplebranch1 = $builder->build({ source => 'Branch' }); >+my $samplebranch2 = $builder->build({ source => 'Branch' }); >+# Add itemtypes >+my $no_circ_itemtype = $builder->build({ >+ source => 'Itemtype', >+ values => { >+ rentalcharge => '0', >+ notforloan => 0 >+ } >+}); >+my $sampleitemtype1 = $builder->build({ >+ source => 'Itemtype', >+ values => { >+ rentalcharge => '10.0', >+ notforloan => 1 >+ } >+}); >+my $sampleitemtype2 = $builder->build({ >+ source => 'Itemtype', >+ values => { >+ rentalcharge => '5.0', >+ notforloan => 0 >+ } >+}); >+# Add Category >+my $samplecat = $builder->build({ >+ source => 'Category', >+ values => { >+ hidelostitems => 0 >+ } >+}); > > #Add biblio and item > my $record = MARC::Record->new(); >@@ -168,13 +98,14 @@ $record->append_fields( > MARC::Field->new( '952', '0', '0', a => $samplebranch1->{branchcode} ) ); > my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( $record, '' ); > >-# item 2 has home branch and holding branch samplebranch1 >+# item 1 has home branch and holding branch samplebranch1 > my @sampleitem1 = C4::Items::AddItem( > { > barcode => 'barcode_1', > itemcallnumber => 'callnumber1', > homebranch => $samplebranch1->{branchcode}, >- holdingbranch => $samplebranch1->{branchcode} >+ holdingbranch => $samplebranch1->{branchcode}, >+ itype => $no_circ_itemtype->{ itemtype } > }, > $biblionumber > ); >@@ -186,7 +117,8 @@ my @sampleitem2 = C4::Items::AddItem( > barcode => 'barcode_2', > itemcallnumber => 'callnumber2', > homebranch => $samplebranch2->{branchcode}, >- holdingbranch => $samplebranch1->{branchcode} >+ holdingbranch => $samplebranch1->{branchcode}, >+ itype => $no_circ_itemtype->{ itemtype } > }, > $biblionumber > ); >@@ -220,7 +152,7 @@ is_deeply( > "Without parameter, GetBranchBorrower returns undef (unilimited) for maxissueqty and maxonsiteissueqty if no rules defined" > ); > >-$query = q| >+my $query = q| > INSERT INTO branch_borrower_circ_rules > (branchcode, categorycode, maxissueqty, maxonsiteissueqty) > VALUES( ?, ?, ?, ? ) >@@ -248,7 +180,7 @@ $dbh->do( $query, {}, 'singleton', 4, 5, 3, 'homebranch' ); > > $query = > "INSERT INTO branch_item_rules (branchcode,itemtype,holdallowed,returnbranch) VALUES( ?,?,?,?)"; >-$sth = $dbh->prepare($query); >+my $sth = $dbh->prepare($query); > $sth->execute( > $samplebranch1->{branchcode}, > $sampleitemtype1->{itemtype}, >@@ -343,5 +275,6 @@ $dbh->do( $query, {}, $borrower_id1, $item_id3, $samplebranch1->{branchcode} ); > $samplebranch1->{branchcode}); > is($messages->{NeedsTransfer},undef,"AddReturn respects branch item return policy - noreturn"); > >+$schema->storage->txn_rollback; > >-$dbh->rollback; >+1; >-- >1.9.1
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 16216
:
49994
|
49995
| 50009