Bugzilla – Attachment 57276 Details for
Bug 17572
Remove issue.t warnings
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 17572: (followup) Remove test's hardcoded values
SIGNED-OFF-Bug-17572-followup-Remove-tests-hardcod.patch (text/plain), 9.73 KB, created by
Josef Moravec
on 2016-11-07 18:27:13 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 17572: (followup) Remove test's hardcoded values
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2016-11-07 18:27:13 UTC
Size:
9.73 KB
patch
obsolete
>From 87a4edec71f48740006d97e43550f5c5b1cb4b71 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 7 Nov 2016 15:09:24 -0300 >Subject: [PATCH] [SIGNED-OFF] Bug 17572: (followup) Remove test's hardcoded > values > >This patch makes the tests use t::lib::TestBuilder instead of >hardcoding values. > >Test plan: >- Run: > $ prove t/db_dependent/Circulation/issue.t >=> SUCCESS: All tests return green with and without the patch >- Sign off :-D > >Sponsored-by: ByWater Solutions > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > t/db_dependent/Circulation/issue.t | 143 ++++++++++++------------------------- > 1 file changed, 47 insertions(+), 96 deletions(-) > >diff --git a/t/db_dependent/Circulation/issue.t b/t/db_dependent/Circulation/issue.t >index b19fc19..cca050b 100644 >--- a/t/db_dependent/Circulation/issue.t >+++ b/t/db_dependent/Circulation/issue.t >@@ -76,89 +76,39 @@ my $itemtype = $builder->build( > value => { notforloan => undef, rentalcharge => 0 } > } > )->{itemtype}; >- >-#Add Dates >- >-my $dt_today = dt_from_string; >-my $today = output_pref({ dt => $dt_today, dateformat => 'iso', timeformat => '24hr', dateonly => 1 }); >+my $branchcode_1 = $builder->build({ source => 'Branch' })->{branchcode}; >+my $branchcode_2 = $builder->build({ source => 'Branch' })->{branchcode}; >+my $categorycode = $builder->build({ >+ source => 'Category', >+ value => { enrolmentfee => undef } >+ })->{categorycode}; >+ >+# Add Dates >+my $dt_today = dt_from_string; >+my $today = output_pref( >+ { dt => $dt_today, >+ dateformat => 'iso', >+ timeformat => '24hr', >+ dateonly => 1 >+ } >+); > > my $dt_today2 = dt_from_string; > my $dur10 = DateTime::Duration->new( days => -10 ); > $dt_today2->add_duration($dur10); >-my $daysago10 = output_pref({ dt => $dt_today2, dateformat => 'iso', timeformat => '24hr', dateonly => 1 }); >- >-#Add branch and category >-my $samplebranch1 = { >- branchcode => 'CPL', >- 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 => 'MPL', >- 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 $daysago10 = output_pref( >+ { dt => $dt_today2, >+ dateformat => 'iso', >+ timeformat => '24hr', >+ dateonly => 1 >+ } > ); > >-#Add biblio and item >+# Add biblio and item > my $record = MARC::Record->new(); > $record->append_fields( >- MARC::Field->new( '952', '0', '0', a => $samplebranch1->{branchcode} ) ); >+ MARC::Field->new( '952', '0', '0', a => $branchcode_1 ) ); >+ > my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( $record, '' ); > > my $barcode_1 = 'barcode_1'; >@@ -167,8 +117,8 @@ my @sampleitem1 = C4::Items::AddItem( > { > barcode => $barcode_1, > itemcallnumber => 'callnumber1', >- homebranch => $samplebranch1->{branchcode}, >- holdingbranch => $samplebranch1->{branchcode}, >+ homebranch => $branchcode_1, >+ holdingbranch => $branchcode_1, > issue => 1, > reserve => 1, > itype => $itemtype >@@ -180,8 +130,8 @@ my @sampleitem2 = C4::Items::AddItem( > { > barcode => $barcode_2, > itemcallnumber => 'callnumber2', >- homebranch => $samplebranch2->{branchcode}, >- holdingbranch => $samplebranch2->{branchcode}, >+ homebranch => $branchcode_2, >+ holdingbranch => $branchcode_2, > notforloan => 1, > issue => 1, > itype => $itemtype >@@ -194,22 +144,23 @@ my $item_id2 = $sampleitem2[2]; > my $borrower_id1 = C4::Members::AddMember( > firstname => 'firstname1', > surname => 'surname1 ', >- categorycode => $samplecat->{categorycode}, >- branchcode => $samplebranch1->{branchcode}, >+ categorycode => $categorycode, >+ branchcode => $branchcode_1 > ); > my $borrower_1 = C4::Members::GetMember(borrowernumber => $borrower_id1); > my $borrower_id2 = C4::Members::AddMember( > firstname => 'firstname2', > surname => 'surname2 ', >- categorycode => $samplecat->{categorycode}, >- branchcode => $samplebranch2->{branchcode}, >+ categorycode => $categorycode, >+ branchcode => $branchcode_2, > ); > my $borrower_2 = C4::Members::GetMember(borrowernumber => $borrower_id2); > >-# NEED TO BE FIXED !!! >-# The first parameter for set_userenv is the class ref >-#my @USERENV = ( $borrower_id1, 'test', 'MASTERTEST', 'firstname', 'username', 'CPL', 'CPL', 'email@example.org' ); >-my @USERENV = ( $borrower_id1, 'test', 'MASTERTEST', 'firstname', 'CPL', 'CPL', 'email@example.org' ); >+my @USERENV = ( >+ $borrower_id1, 'test', 'MASTERTEST', 'firstname', $branchcode_1, >+ $branchcode_1, 'email@example.org' >+); >+ > > C4::Context->_new_userenv('DUMMY_SESSION_ID'); > C4::Context->set_userenv(@USERENV); >@@ -220,7 +171,7 @@ my $userenv = C4::Context->userenv > #Begin Tests > > #Test AddIssue >-$query = " SELECT count(*) FROM issues"; >+my $query = " SELECT count(*) FROM issues"; > my $sth = $dbh->prepare($query); > $sth->execute; > my $countissue = $sth -> fetchrow_array; >@@ -259,7 +210,7 @@ is ($countaccount,1,"1 accountline has been added"); > > #Test AddRenewal > my $datedue3 = >- AddRenewal( $borrower_id1, $item_id1, $samplebranch1->{branchcode}, >+ AddRenewal( $borrower_id1, $item_id1, $branchcode_1, > $datedue1, $daysago10 ); > like( > $datedue3, >@@ -356,7 +307,7 @@ is_deeply( > "With issuing rules (renewal allowed) and with a valid parameter, Getrenewcount of item1 returns 3 renews left" > ); > >-AddRenewal( $borrower_id1, $item_id1, $samplebranch1->{branchcode}, >+AddRenewal( $borrower_id1, $item_id1, $branchcode_1, > $datedue3, $daysago10 ); > @renewcount = C4::Circulation::GetRenewCount($borrower_id1, $item_id1); > is_deeply( >@@ -381,8 +332,8 @@ my $itemnumber; > { > barcode => 'barcode_3', > itemcallnumber => 'callnumber3', >- homebranch => $samplebranch1->{branchcode}, >- holdingbranch => $samplebranch1->{branchcode}, >+ homebranch => $branchcode_1, >+ holdingbranch => $branchcode_1, > notforloan => 1, > itype => $itemtype > }, >@@ -390,21 +341,21 @@ my $itemnumber; > ); > > t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', q{} ); >-AddReturn( 'barcode_3', $samplebranch1->{branchcode} ); >+AddReturn( 'barcode_3', $branchcode_1 ); > my $item = GetItem( $itemnumber ); > ok( $item->{notforloan} eq 1, 'UpdateNotForLoanStatusOnCheckin does not modify value when not enabled' ); > > t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '1: 9' ); >-AddReturn( 'barcode_3', $samplebranch1->{branchcode} ); >+AddReturn( 'barcode_3', $branchcode_1 ); > $item = GetItem( $itemnumber ); > ok( $item->{notforloan} eq 9, q{UpdateNotForLoanStatusOnCheckin updates notforloan value from 1 to 9 with setting "1: 9"} ); > >-AddReturn( 'barcode_3', $samplebranch1->{branchcode} ); >+AddReturn( 'barcode_3', $branchcode_1 ); > $item = GetItem( $itemnumber ); > ok( $item->{notforloan} eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9"} ); > > # Bug 14640 - Cancel the hold on checking out if asked >-my $reserve_id = AddReserve('CPL', $borrower_id1, $biblionumber, >+my $reserve_id = AddReserve($branchcode_1, $borrower_id1, $biblionumber, > undef, 1, undef, undef, "a note", "a title", undef, ''); > ok( $reserve_id, 'The reserve should have been inserted' ); > AddIssue( $borrower_2, $barcode_1, dt_from_string, 'cancel' ); >-- >2.1.4
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 17572
:
57272
|
57273
|
57275
|
57276
|
57449
|
57450
|
57451