Bugzilla – Attachment 48580 Details for
Bug 14694
Make decreaseloanHighHolds more flexible
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14694: Create data the tests need
Bug-14694-Create-data-the-tests-need.patch (text/plain), 4.01 KB, created by
Mark Tompsett
on 2016-03-03 04:27:15 UTC
(
hide
)
Description:
Bug 14694: Create data the tests need
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2016-03-03 04:27:15 UTC
Size:
4.01 KB
patch
obsolete
>From 160c43a65d86f93effdf0d64e709d26d1732a7fb Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 19 Jan 2016 13:30:56 +0000 >Subject: [PATCH] Bug 14694: Create data the tests need > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > t/db_dependent/DecreaseLoanHighHolds.t | 37 +++++++++++++++++++++++----------- > 1 file changed, 25 insertions(+), 12 deletions(-) > >diff --git a/t/db_dependent/DecreaseLoanHighHolds.t b/t/db_dependent/DecreaseLoanHighHolds.t >index 5f5549e..e13917a 100755 >--- a/t/db_dependent/DecreaseLoanHighHolds.t >+++ b/t/db_dependent/DecreaseLoanHighHolds.t >@@ -17,8 +17,6 @@ > > use Modern::Perl; > >-use DateTime; >- > use C4::Circulation; > use Koha::Database; > use Koha::Borrower; >@@ -26,11 +24,13 @@ use Koha::Biblio; > use Koha::Item; > use Koha::Holds; > use Koha::Hold; >+use t::lib::TestBuilder; > > use Test::More tests => 12; > > my $dbh = C4::Context->dbh; > my $schema = Koha::Database->new()->schema(); >+my $builder = t::lib::TestBuilder->new; > > # Start transaction > $dbh->{RaiseError} = 1; >@@ -41,15 +41,18 @@ $dbh->do('DELETE FROM issuingrules'); > $dbh->do('DELETE FROM borrowers'); > $dbh->do('DELETE FROM items'); > >+my $library = $builder->build({source => 'Branch'}); >+my $category = $builder->build({source => 'Category'}); >+ > # Set userenv > C4::Context->_new_userenv('xxx'); >-C4::Context->set_userenv( 0, 0, 0, 'firstname', 'surname', 'MPL', 'Midway Public Library', '', '', '' ); >-is( C4::Context->userenv->{branch}, 'MPL', 'userenv set' ); >+C4::Context->set_userenv( 0, 0, 0, 'firstname', 'surname', $library->{branchcode}, 'Midway Public Library', '', '', '' ); >+is( C4::Context->userenv->{branch}, $library->{branchcode}, 'userenv set' ); > > my @patrons; > for my $i ( 1 .. 20 ) { > my $patron = Koha::Borrower->new( >- { cardnumber => $i, firstname => 'Kyle', surname => 'Hall', categorycode => 'S', branchcode => 'MPL' } ) >+ { cardnumber => $i, firstname => 'Kyle', surname => 'Hall', categorycode => $category->{categorycode}, branchcode => $library->{branchcode} } ) > ->store(); > push( @patrons, $patron ); > } >@@ -70,14 +73,24 @@ for my $i ( 0 .. 5 ) { > { > borrowernumber => $patron->id, > biblionumber => $biblio->id, >- branchcode => 'MPL', >+ branchcode => $library->{branchcode}, > } > )->store(); > } > >-$schema->resultset('Issuingrule') >- ->new( { branchcode => '*', categorycode => '*', itemtype => '*', issuelength => '14', lengthunit => 'days', reservesallowed => '99' } ) >- ->insert(); >+$builder->build( >+ { >+ source => 'Issuingrule', >+ value => { >+ branchcode => '*', >+ categorycode => '*', >+ itemtype => '*', >+ issuelength => '14', >+ lengthunit => 'days', >+ reservesallowed => '99', >+ } >+ } >+); > > my $item = pop(@items); > my $patron = pop(@patrons); >@@ -88,8 +101,8 @@ C4::Context->set_preference( 'decreaseLoanHighHoldsValue', 1 ); > C4::Context->set_preference( 'decreaseLoanHighHoldsControl', 'static' ); > C4::Context->set_preference( 'decreaseLoanHighHoldsIgnoreStatuses', 'damaged,itemlost,notforloan,withdrawn' ); > >-my $item_hr = { itemnumber => $item->id, biblionumber => $biblio->id, homebranch => 'MPL', holdingbranch => 'MPL' }; >-my $patron_hr = { borrower => $patron->id, branchcode => 'MPL' }; >+my $item_hr = { itemnumber => $item->id, biblionumber => $biblio->id, homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode} }; >+my $patron_hr = { borrower => $patron->id, branchcode => $library->{branchcode} }; > > my $data = C4::Circulation::checkHighHolds( $item_hr, $patron_hr ); > is( $data->{exceeded}, 1, "Static mode should exceed threshold" ); >@@ -107,7 +120,7 @@ for my $i ( 5 .. 10 ) { > { > borrowernumber => $patron->id, > biblionumber => $biblio->id, >- branchcode => 'MPL', >+ branchcode => $library->{branchcode}, > } > )->store(); > } >-- >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 14694
:
42957
|
42958
|
42970
|
43153
|
43513
|
43589
|
43598
|
43752
|
43768
|
43952
|
46532
|
46533
|
46534
|
46535
|
46864
|
46865
|
46866
|
46867
|
46868
|
48576
|
48577
|
48578
|
48579
|
48580
|
48678
|
48804