Bugzilla – Attachment 108730 Details for
Bug 26250
Test suite does not pass if Elastic is used as search engine
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26250: Fix tests when SearchEngine=Elastic
Bug-26250-Fix-tests-when-SearchEngineElastic.patch (text/plain), 228.91 KB, created by
Nick Clemens (kidclamp)
on 2020-08-20 11:27:33 UTC
(
hide
)
Description:
Bug 26250: Fix tests when SearchEngine=Elastic
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2020-08-20 11:27:33 UTC
Size:
228.91 KB
patch
obsolete
>From fdaf4c578975a413b28f6c4f3feff46ee3996473 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 19 Aug 2020 14:03:29 +0200 >Subject: [PATCH] Bug 26250: Fix tests when SearchEngine=Elastic > >Most of the time the tests are failing because the item is not created >correctly (missing biblio and/or biblioitem). >The usual error is: > t/db_dependent/selenium/regressions.t ..... 5/5 Can't call method "leader" on an undefined value at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch.pm line 534. > >In this patch we are making sure $builder->build({ source => 'Item' }) >is replace with $builder->build_sample_item > >Test plan: >Turn on Elastic and confirm that all the tests pass! > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > t/db_dependent/Accounts.t | 12 +- > t/db_dependent/Acquisition.t | 6 +- > t/db_dependent/ArticleRequests.t | 27 +- > t/db_dependent/Barcodes.t | 28 +- > t/db_dependent/Barcodes_ValueBuilder.t | 28 +- > t/db_dependent/Biblio/ModBiblioMarc.t | 6 +- > t/db_dependent/Budgets.t | 12 +- > t/db_dependent/Circulation.t | 325 ++++++++++----------- > t/db_dependent/Circulation/CalcFine.t | 44 ++- > t/db_dependent/Circulation/MarkIssueReturned.t | 42 +-- > .../Circulation/NoIssuesChargeGuarantees.t | 15 +- > t/db_dependent/Circulation/ReturnClaims.t | 26 +- > t/db_dependent/Circulation/Returns.t | 148 +++------- > t/db_dependent/Circulation/StoreLastBorrower.t | 48 ++- > t/db_dependent/Circulation/SwitchOnSiteCheckouts.t | 75 ++--- > t/db_dependent/Circulation/dateexpiry.t | 22 +- > t/db_dependent/CourseReserves/CourseItems.t | 25 +- > t/db_dependent/Exporter/Record.t | 47 +-- > t/db_dependent/Holds/HoldFulfillmentPolicy.t | 2 +- > t/db_dependent/Holds/WaitingReserves.t | 78 ++--- > t/db_dependent/ILSDI_Services.t | 156 +++------- > t/db_dependent/ImportBatch.t | 2 +- > t/db_dependent/Items.t | 19 +- > t/db_dependent/Items/GetHostItemsInfo.t | 12 +- > t/db_dependent/Items/GetItemsForInventory.t | 2 +- > t/db_dependent/Items/MoveItemFromBiblio.t | 64 ++-- > t/db_dependent/Koha/Account/Line.t | 19 +- > t/db_dependent/Koha/Biblios.t | 14 +- > t/db_dependent/Koha/Checkouts.t | 12 +- > .../Koha/Filter/EmbedItemsAvailability.t | 66 ++--- > t/db_dependent/Koha/Item.t | 36 ++- > t/db_dependent/Koha/Item/Transfers.t | 22 +- > t/db_dependent/Koha/Patrons.t | 225 +++++--------- > t/db_dependent/Koha/Ratings.t | 4 +- > t/db_dependent/Koha/Reviews.t | 10 +- > t/db_dependent/Koha/SharedContent.t | 22 +- > t/db_dependent/Koha/Subscription.t | 23 +- > t/db_dependent/Koha/Suggestions.t | 10 +- > t/db_dependent/Koha/Z3950Responder/Session.t | 34 +-- > t/db_dependent/Koha/Z3950Responder/Session2.t | 34 +-- > t/db_dependent/Letters/TemplateToolkit.t | 57 ++-- > t/db_dependent/Reserves.t | 7 +- > t/db_dependent/Reserves/CancelExpiredReserves.t | 12 +- > t/db_dependent/Reserves/GetReserveFee.t | 75 +++-- > t/db_dependent/Reserves/MultiplePerRecord.t | 84 ++---- > t/db_dependent/Reserves/ReserveSlip.t | 41 +-- > t/db_dependent/SIP/Message.t | 20 +- > t/db_dependent/StockRotationRotas.t | 10 +- > t/db_dependent/Virtualshelves.t | 71 +++-- > t/db_dependent/api/v1/items.t | 6 +- > t/db_dependent/cronjobs/advance_notices_digest.t | 27 +- > t/db_dependent/rollingloans.t | 24 +- > t/db_dependent/selenium/regressions.t | 13 +- > 53 files changed, 820 insertions(+), 1429 deletions(-) > >diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t >index 56665ae7cf..12e11f5ede 100644 >--- a/t/db_dependent/Accounts.t >+++ b/t/db_dependent/Accounts.t >@@ -75,7 +75,7 @@ my $userenv_branchcode = $branchcode; > > # Test manualinvoice > my $itemtype = $builder->build( { source => 'Itemtype' } ); >-my $item = $builder->build( { source => 'Item', value => { itype => $itemtype->{itemtype} } } ); >+my $item = $builder->build_sample_item( { itype => $itemtype->{itemtype} } ); > my $patron = $builder->build( { source => 'Borrower' } ); > my $amount = 5; > my $description = "Test fee!"; >@@ -83,7 +83,7 @@ my $type = 'LOST'; > my $note = 'Test note!'; > warning_like { > C4::Accounts::manualinvoice( $patron->{borrowernumber}, >- $item->{itemnumber}, $description, $type, $amount, $note ) >+ $item->itemnumber, $description, $type, $amount, $note ) > } > qr/C4::Accounts::manualinvoice is deprecated in favor of Koha::Account->add_debit/, > "deprecation warning received for manualinvoice"; >@@ -586,10 +586,10 @@ subtest "C4::Accounts::chargelostitem tests" => sub { > processfee => 2.04, > }}); > my $cli_borrowernumber = $builder->build({ source => 'Borrower' })->{'borrowernumber'}; >- my $cli_itemnumber1 = $builder->build({ source => 'Item', value => { itype => $itype_no_replace_no_fee->{itemtype} } })->{'itemnumber'}; >- my $cli_itemnumber2 = $builder->build({ source => 'Item', value => { itype => $itype_replace_no_fee->{itemtype} } })->{'itemnumber'}; >- my $cli_itemnumber3 = $builder->build({ source => 'Item', value => { itype => $itype_no_replace_fee->{itemtype} } })->{'itemnumber'}; >- my $cli_itemnumber4 = $builder->build({ source => 'Item', value => { itype => $itype_replace_fee->{itemtype} } })->{'itemnumber'}; >+ my $cli_itemnumber1 = $builder->build_sample_item({ itype => $itype_no_replace_no_fee->{itemtype} })->itemnumber; >+ my $cli_itemnumber2 = $builder->build_sample_item({ itype => $itype_replace_no_fee->{itemtype} })->itemnumber; >+ my $cli_itemnumber3 = $builder->build_sample_item({ itype => $itype_no_replace_fee->{itemtype} })->itemnumber; >+ my $cli_itemnumber4 = $builder->build_sample_item({ itype => $itype_replace_fee->{itemtype} })->itemnumber; > > my $cli_issue_id_1 = $builder->build({ source => 'Issue', value => { borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber1 } })->{issue_id}; > my $cli_issue_id_2 = $builder->build({ source => 'Issue', value => { borrowernumber => $cli_borrowernumber, itemnumber => $cli_itemnumber2 } })->{issue_id}; >diff --git a/t/db_dependent/Acquisition.t b/t/db_dependent/Acquisition.t >index 912a451e25..6028fea2b3 100755 >--- a/t/db_dependent/Acquisition.t >+++ b/t/db_dependent/Acquisition.t >@@ -698,7 +698,7 @@ subtest 'ModReceiveOrder replacementprice tests' => sub { > plan tests => 2; > #Let's build an order, we need a couple things though > my $builder = t::lib::TestBuilder->new; >- my $order_biblio = $builder->build({ source => 'Biblio' }); >+ my $order_biblio = $builder->build_sample_biblio; > my $order_basket = $builder->build({ source => 'Aqbasket', value => { is_standing => 0 } }); > my $order_invoice = $builder->build({ source => 'Aqinvoice'}); > my $order_currency = $builder->build({ source => 'Currency', value => { active => 1, archived => 0, symbol => 'F', rate => 2, isocode => undef, currency => 'FOO' } }); >@@ -715,7 +715,7 @@ subtest 'ModReceiveOrder replacementprice tests' => sub { > }; > my $receive_order = $builder->build({ source => 'Aqorder', value => $orderinfo }); > (undef, my $received_ordernumber) = ModReceiveOrder({ >- biblionumber => $order_biblio->{biblionumber}, >+ biblionumber => $order_biblio->biblionumber, > order => $receive_order, > invoice => $order_invoice, > quantityreceived => $receive_order->{quantity}, >@@ -726,7 +726,7 @@ subtest 'ModReceiveOrder replacementprice tests' => sub { > $orderinfo->{replacementprice} = 16.12; > $receive_order = $builder->build({ source => 'Aqorder', value => $orderinfo }); > (undef, $received_ordernumber) = ModReceiveOrder({ >- biblionumber => $order_biblio->{biblionumber}, >+ biblionumber => $order_biblio->biblionumber, > order => $receive_order, > invoice => $order_invoice, > quantityreceived => $receive_order->{quantity}, >diff --git a/t/db_dependent/ArticleRequests.t b/t/db_dependent/ArticleRequests.t >index 7baaefbc51..3f0ec37cd3 100755 >--- a/t/db_dependent/ArticleRequests.t >+++ b/t/db_dependent/ArticleRequests.t >@@ -19,7 +19,7 @@ use Modern::Perl; > > use POSIX qw(strftime); > >-use Test::More tests => 57; >+use Test::More tests => 54; > > use t::lib::TestBuilder; > use t::lib::Mocks; >@@ -47,25 +47,8 @@ my $dbh = C4::Context->dbh; > > $dbh->do("DELETE FROM circulation_rules"); > >-my $biblio = Koha::Biblio->new()->store(); >-ok( $biblio->id, 'Koha::Biblio created' ); >- >-my $biblioitem = $schema->resultset('Biblioitem')->new( >- { >- biblionumber => $biblio->id >- } >-)->insert(); >-ok( $biblioitem->id, 'biblioitem created' ); >- >-my $itype = $builder->build({ source => 'Itemtype' }); >-my $item = Koha::Item->new( >- { >- biblionumber => $biblio->id, >- biblioitemnumber => $biblioitem->id, >- itype => $itype->{itemtype}, >- } >-)->store(); >-ok( $item->id, 'Koha::Item created' ); >+my $item = $builder->build_sample_item; >+my $biblio = $item->biblio; > > my $branch = $builder->build({ source => 'Branch' }); > my $category = $builder->build({ source => 'Category' }); >@@ -86,8 +69,8 @@ my $article_request_title = 'an article request title'; > my $article_request = Koha::ArticleRequest->new( > { > borrowernumber => $patron->id, >- biblionumber => $biblio->id, >- itemnumber => $item->id, >+ biblionumber => $item->biblionumber, >+ itemnumber => $item->itemnumber, > title => $article_request_title, > } > )->store(); >diff --git a/t/db_dependent/Barcodes.t b/t/db_dependent/Barcodes.t >index f00f8b5789..4253a615eb 100755 >--- a/t/db_dependent/Barcodes.t >+++ b/t/db_dependent/Barcodes.t >@@ -50,12 +50,11 @@ subtest 'Test generation of annual barcodes from DB values' => sub { > > my $barcodevalue = $barcodeobj->value(); > >- my $item_1 = $builder->build({ >- source => 'Item', >- value => { >+ my $item_1 = $builder->build_sample_item( >+ { > barcode => $barcodevalue > } >- }); >+ ); > > is($barcodevalue,$barcodeobj->db_max(), "(annual) First barcode saved to db is equal to db_max" ); > >@@ -66,12 +65,11 @@ subtest 'Test generation of annual barcodes from DB values' => sub { > $barcodevalue = $barcodeobj->next_value($barcodevalue); > $barcodevalue = $barcodeobj->next_value($barcodevalue); > >- my $item_2 = $builder->build({ >- source => 'Item', >- value => { >+ my $item_2 = $builder->build_sample_item( >+ { > barcode => $barcodevalue > } >- }); >+ ); > > $barcodeobj = C4::Barcodes->new('annual'); > >@@ -105,12 +103,11 @@ subtest 'Test generation of hbyymmincr barcodes from DB values' => sub { > > my $barcodevalue = $barcodeobj->value(); > >- my $item_1 = $builder->build({ >- source => 'Item', >- value => { >+ my $item_1 = $builder->build_sample_item( >+ { > barcode => $barcodevalue > } >- }); >+ ); > > is($barcodevalue,$barcodeobj->db_max(), "(hbyymmincr) First barcode saved to db is equal to db_max" ); > >@@ -121,12 +118,11 @@ subtest 'Test generation of hbyymmincr barcodes from DB values' => sub { > $barcodevalue = $barcodeobj->next_value($barcodevalue); > $barcodevalue = $barcodeobj->next_value($barcodevalue); > >- my $item_2 = $builder->build({ >- source => 'Item', >- value => { >+ my $item_2 = $builder->build_sample_item( >+ { > barcode => $barcodevalue > } >- }); >+ ); > > $barcodeobj = C4::Barcodes->new('hbyymmincr',$branchcode_1); > >diff --git a/t/db_dependent/Barcodes_ValueBuilder.t b/t/db_dependent/Barcodes_ValueBuilder.t >index 7573bbd0da..ef0fa3a39b 100644 >--- a/t/db_dependent/Barcodes_ValueBuilder.t >+++ b/t/db_dependent/Barcodes_ValueBuilder.t >@@ -34,30 +34,26 @@ my $builder = t::lib::TestBuilder->new; > my $dbh = C4::Context->dbh; > $dbh->do(q|DELETE FROM issues|); > $dbh->do(q|DELETE FROM items|); >-my $item_1 = $builder->build({ >- source => 'Item', >- value => { >+my $item_1 = $builder->build_sample_item( >+ { > barcode => '33333074344563' > } >-}); >-my $item_2 = $builder->build({ >- source => 'Item', >- value => { >+); >+my $item_2 = $builder->build_sample_item( >+ { > barcode => 'hb12070890' > } >-}); >-my $item_3 = $builder->build({ >- source => 'Item', >- value => { >+); >+my $item_3 = $builder->build_sample_item( >+ { > barcode => '201200345' > } >-}); >-my $item_4 = $builder->build({ >- source => 'Item', >- value => { >+); >+my $item_4 = $builder->build_sample_item( >+ { > barcode => '2012-0034' > } >-}); >+); > > my %args = ( > year => '2012', >diff --git a/t/db_dependent/Biblio/ModBiblioMarc.t b/t/db_dependent/Biblio/ModBiblioMarc.t >index 3eaf4f73b3..94cf62d6f0 100644 >--- a/t/db_dependent/Biblio/ModBiblioMarc.t >+++ b/t/db_dependent/Biblio/ModBiblioMarc.t >@@ -33,15 +33,15 @@ subtest "Check MARC field length calculation" => sub { > > t::lib::Mocks->mock_preference( 'marcflavour', 'MARC21' ); > >- my $biblio = t::lib::TestBuilder->new->build({ source => 'Biblio' }); >+ my $biblio = t::lib::TestBuilder->new->build_sample_biblio; > my $record = MARC::Record->new; > $record->append_fields( > MARC::Field->new( '100', '', '', a => 'My title' ), > ); > > is( $record->leader, ' 'x24, 'No leader lengths' ); >- C4::Biblio::ModBiblioMarc( $record, $biblio->{biblionumber}, '' ); >- my $savedrec = C4::Biblio::GetMarcBiblio({ biblionumber => $biblio->{biblionumber} }); >+ C4::Biblio::ModBiblioMarc( $record, $biblio->biblionumber, '' ); >+ my $savedrec = C4::Biblio::GetMarcBiblio({ biblionumber => $biblio->biblionumber }); > like( substr($savedrec->leader,0,5), qr/^\d{5}$/, 'Record length found' ); > like( substr($savedrec->leader,12,5), qr/^\d{5}$/, 'Base address found' ); > }; >diff --git a/t/db_dependent/Budgets.t b/t/db_dependent/Budgets.t >index 339d5bd6e4..bf3855db01 100755 >--- a/t/db_dependent/Budgets.t >+++ b/t/db_dependent/Budgets.t >@@ -968,9 +968,7 @@ subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub { > #Let's build an order, we need a couple things though > t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent'); > >- my $spent_biblio = $builder->build({ source => 'Biblio' }); >- my $item_1 = $builder->build({ source => 'Item', value => { biblionumber => $spent_biblio->{biblionumber} } }); >- my $biblioitem_1 = $builder->build({ source => 'Biblioitem', value => { biblionumber => $spent_biblio->{biblionumber}, itemnumber => $item_1->{itemnumber} } }); >+ my $item_1 = $builder->build_sample_item; > my $spent_basket = $builder->build({ source => 'Aqbasket', value => { is_standing => 0 } }); > my $spent_invoice = $builder->build({ source => 'Aqinvoice'}); > my $spent_currency = $builder->build({ source => 'Currency', value => { active => 1, archived => 0, symbol => 'F', rate => 2, isocode => undef, currency => 'FOO' } }); >@@ -996,7 +994,7 @@ subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub { > rrp => 16.99, > discount => .42, > ecost => 16.91, >- biblionumber => $spent_biblio->{biblionumber}, >+ biblionumber => $item_1->biblionumber, > currency => $spent_currency->{currency}, > tax_rate_on_ordering => 0, > tax_value_on_ordering => 0, >@@ -1045,7 +1043,7 @@ subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub { > #Let's test some budget planning > #Regression tests for bug 18736 > #We need an item to test by BRANCHES >- my $order_item_1 = $builder->build({ source => 'AqordersItem', value => { ordernumber => $spent_order->{ordernumber}, itemnumber => $item_1->{itemnumber} } }); >+ my $order_item_1 = $builder->build({ source => 'AqordersItem', value => { ordernumber => $spent_order->{ordernumber}, itemnumber => $item_1->itemnumber } }); > my $spent_fund = Koha::Acquisition::Funds->find( $spent_order->{budget_id} ); > my $cell = { > authcat => 'MONTHS', >@@ -1062,12 +1060,12 @@ subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub { > expected_exact => 9.8542, > }, > 'BRANCHES' => { >- authvalue => $item_1->{homebranch}, >+ authvalue => $item_1->homebranch, > expected_rounded => 9.85, > expected_exact => 9.8542, > }, > 'ITEMTYPES' => { >- authvalue => $biblioitem_1->{itemtype}, >+ authvalue => $item_1->biblioitem->itemtype, > expected_rounded => 78.80, > expected_exact => 78.8336, > }, >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 1dbf754d91..f26f2f3255 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -83,9 +83,9 @@ sub test_debarment_on_checkout { > ); > my @caller = caller; > my $line_number = $caller[2]; >- AddIssue( $patron, $item->{barcode}, $due_date ); >+ AddIssue( $patron, $item->barcode, $due_date ); > >- my ( undef, $message ) = AddReturn( $item->{barcode}, $library->{branchcode}, undef, $return_date ); >+ my ( undef, $message ) = AddReturn( $item->barcode, $library->{branchcode}, undef, $return_date ); > is( $message->{WasReturned} && exists $message->{Debarred}, 1, 'AddReturn must have debarred the patron' ) > or diag('AddReturn returned message ' . Dumper $message ); > my $debarments = Koha::Patron::Debarments::GetDebarments( >@@ -749,19 +749,16 @@ subtest "CanBookBeRenewed tests" => sub { > > subtest "too_late_renewal / no_auto_renewal_after" => sub { > plan tests => 14; >- my $item_to_auto_renew = $builder->build( >- { source => 'Item', >- value => { >- biblionumber => $biblio->biblionumber, >- homebranch => $branch, >- holdingbranch => $branch, >- } >+ my $item_to_auto_renew = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $branch, > } > ); > > my $ten_days_before = dt_from_string->add( days => -10 ); > my $ten_days_ahead = dt_from_string->add( days => 10 ); >- AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); >+ AddIssue( $renewing_borrower, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); > > Koha::CirculationRules->set_rules( > { >@@ -775,7 +772,7 @@ subtest "CanBookBeRenewed tests" => sub { > } > ); > ( $renewokay, $error ) = >- CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); >+ CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); > is( $renewokay, 0, 'Do not renew, renewal is automatic' ); > is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); > >@@ -791,7 +788,7 @@ subtest "CanBookBeRenewed tests" => sub { > } > ); > ( $renewokay, $error ) = >- CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); >+ CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); > is( $renewokay, 0, 'Do not renew, renewal is automatic' ); > is( $error, 'auto_too_late', 'Cannot auto renew, too late - no_auto_renewal_after is inclusive(returned code is auto_too_late)' ); > >@@ -807,7 +804,7 @@ subtest "CanBookBeRenewed tests" => sub { > } > ); > ( $renewokay, $error ) = >- CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); >+ CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); > is( $renewokay, 0, 'Do not renew, renewal is automatic' ); > is( $error, 'auto_too_soon', 'Cannot auto renew, too soon - no_auto_renewal_after is defined(returned code is auto_too_soon)' ); > >@@ -823,7 +820,7 @@ subtest "CanBookBeRenewed tests" => sub { > } > ); > ( $renewokay, $error ) = >- CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); >+ CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); > is( $renewokay, 0, 'Do not renew, renewal is automatic' ); > is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); > >@@ -840,7 +837,7 @@ subtest "CanBookBeRenewed tests" => sub { > } > ); > ( $renewokay, $error ) = >- CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); >+ CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); > is( $renewokay, 0, 'Do not renew, renewal is automatic' ); > is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); > >@@ -857,7 +854,7 @@ subtest "CanBookBeRenewed tests" => sub { > } > ); > ( $renewokay, $error ) = >- CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); >+ CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); > is( $renewokay, 0, 'Do not renew, renewal is automatic' ); > is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); > >@@ -874,25 +871,23 @@ subtest "CanBookBeRenewed tests" => sub { > } > ); > ( $renewokay, $error ) = >- CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); >+ CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); > is( $renewokay, 0, 'Do not renew, renewal is automatic' ); > is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); > }; > > subtest "auto_too_much_oweing | OPACFineNoRenewalsBlockAutoRenew & OPACFineNoRenewalsIncludeCredit" => sub { > plan tests => 10; >- my $item_to_auto_renew = $builder->build({ >- source => 'Item', >- value => { >+ my $item_to_auto_renew = $builder->build_sample_item( >+ { > biblionumber => $biblio->biblionumber, >- homebranch => $branch, >- holdingbranch => $branch, >+ library => $branch, > } >- }); >+ ); > > my $ten_days_before = dt_from_string->add( days => -10 ); > my $ten_days_ahead = dt_from_string->add( days => 10 ); >- AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); >+ AddIssue( $renewing_borrower, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); > > Koha::CirculationRules->set_rules( > { >@@ -915,12 +910,12 @@ subtest "CanBookBeRenewed tests" => sub { > amount => $fines_amount, > interface => 'test', > type => 'OVERDUE', >- item_id => $item_to_auto_renew->{itemnumber}, >+ item_id => $item_to_auto_renew->itemnumber, > description => "Some fines" > } > )->status('RETURNED')->store; > ( $renewokay, $error ) = >- CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); >+ CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); > is( $renewokay, 0, 'Do not renew, renewal is automatic' ); > is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 5' ); > >@@ -929,12 +924,12 @@ subtest "CanBookBeRenewed tests" => sub { > amount => $fines_amount, > interface => 'test', > type => 'OVERDUE', >- item_id => $item_to_auto_renew->{itemnumber}, >+ item_id => $item_to_auto_renew->itemnumber, > description => "Some fines" > } > )->status('RETURNED')->store; > ( $renewokay, $error ) = >- CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); >+ CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); > is( $renewokay, 0, 'Do not renew, renewal is automatic' ); > is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 10' ); > >@@ -943,12 +938,12 @@ subtest "CanBookBeRenewed tests" => sub { > amount => $fines_amount, > interface => 'test', > type => 'OVERDUE', >- item_id => $item_to_auto_renew->{itemnumber}, >+ item_id => $item_to_auto_renew->itemnumber, > description => "Some fines" > } > )->status('RETURNED')->store; > ( $renewokay, $error ) = >- CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); >+ CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); > is( $renewokay, 0, 'Do not renew, renewal is automatic' ); > is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, patron has 15' ); > >@@ -961,13 +956,13 @@ subtest "CanBookBeRenewed tests" => sub { > } > )->store; > ( $renewokay, $error ) = >- CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); >+ CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); > is( $renewokay, 0, 'Do not renew, renewal is automatic' ); > is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, OPACFineNoRenewalsIncludeCredit=1, patron has 15 debt, 5 credit' ); > > C4::Context->set_preference('OPACFineNoRenewalsIncludeCredit','0'); > ( $renewokay, $error ) = >- CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); >+ CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); > is( $renewokay, 0, 'Do not renew, renewal is automatic' ); > is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, OPACFineNoRenewalsIncludeCredit=1, patron has 15 debt, 5 credit' ); > >@@ -977,14 +972,12 @@ subtest "CanBookBeRenewed tests" => sub { > > subtest "auto_account_expired | BlockExpiredPatronOpacActions" => sub { > plan tests => 6; >- my $item_to_auto_renew = $builder->build({ >- source => 'Item', >- value => { >+ my $item_to_auto_renew = $builder->build_sample_item( >+ { > biblionumber => $biblio->biblionumber, >- homebranch => $branch, >- holdingbranch => $branch, >+ library => $branch, > } >- }); >+ ); > > Koha::CirculationRules->set_rules( > { >@@ -1005,9 +998,9 @@ subtest "CanBookBeRenewed tests" => sub { > # => auto renew is allowed > t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 0); > my $patron = $expired_borrower; >- my $checkout = AddIssue( $patron, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); >+ my $checkout = AddIssue( $patron, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); > ( $renewokay, $error ) = >- CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->{itemnumber} ); >+ CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->itemnumber ); > is( $renewokay, 0, 'Do not renew, renewal is automatic' ); > is( $error, 'auto_renew', 'Can auto renew, patron is expired but BlockExpiredPatronOpacActions=0' ); > Koha::Checkouts->find( $checkout->issue_id )->delete; >@@ -1017,9 +1010,9 @@ subtest "CanBookBeRenewed tests" => sub { > # => auto renew is not allowed > t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1); > $patron = $expired_borrower; >- $checkout = AddIssue( $patron, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); >+ $checkout = AddIssue( $patron, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); > ( $renewokay, $error ) = >- CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->{itemnumber} ); >+ CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->itemnumber ); > is( $renewokay, 0, 'Do not renew, renewal is automatic' ); > is( $error, 'auto_account_expired', 'Can not auto renew, lockExpiredPatronOpacActions=1 and patron is expired' ); > Koha::Checkouts->find( $checkout->issue_id )->delete; >@@ -1029,9 +1022,9 @@ subtest "CanBookBeRenewed tests" => sub { > # => auto renew is allowed > t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 1); > $patron = $renewing_borrower; >- $checkout = AddIssue( $patron, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); >+ $checkout = AddIssue( $patron, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); > ( $renewokay, $error ) = >- CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->{itemnumber} ); >+ CanBookBeRenewed( $patron->{borrowernumber}, $item_to_auto_renew->itemnumber ); > is( $renewokay, 0, 'Do not renew, renewal is automatic' ); > is( $error, 'auto_renew', 'Can auto renew, BlockExpiredPatronOpacActions=1 but patron is not expired' ); > Koha::Checkouts->find( $checkout->issue_id )->delete; >@@ -1039,19 +1032,16 @@ subtest "CanBookBeRenewed tests" => sub { > > subtest "GetLatestAutoRenewDate" => sub { > plan tests => 5; >- my $item_to_auto_renew = $builder->build( >- { source => 'Item', >- value => { >- biblionumber => $biblio->biblionumber, >- homebranch => $branch, >- holdingbranch => $branch, >- } >+ my $item_to_auto_renew = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $branch, > } > ); > > my $ten_days_before = dt_from_string->add( days => -10 ); > my $ten_days_ahead = dt_from_string->add( days => 10 ); >- AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); >+ AddIssue( $renewing_borrower, $item_to_auto_renew->barcode, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); > Koha::CirculationRules->set_rules( > { > categorycode => undef, >@@ -1064,7 +1054,7 @@ subtest "CanBookBeRenewed tests" => sub { > } > } > ); >- my $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); >+ my $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); > is( $latest_auto_renew_date, undef, 'GetLatestAutoRenewDate should return undef if no_auto_renewal_after or no_auto_renewal_after_hard_limit are not defined' ); > my $five_days_before = dt_from_string->add( days => -5 ); > Koha::CirculationRules->set_rules( >@@ -1079,7 +1069,7 @@ subtest "CanBookBeRenewed tests" => sub { > } > } > ); >- $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); >+ $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); > is( $latest_auto_renew_date->truncate( to => 'minute' ), > $five_days_before->truncate( to => 'minute' ), > 'GetLatestAutoRenewDate should return -5 days if no_auto_renewal_after = 5 and date_due is 10 days before' >@@ -1100,7 +1090,7 @@ subtest "CanBookBeRenewed tests" => sub { > } > } > ); >- $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); >+ $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); > is( $latest_auto_renew_date->truncate( to => 'minute' ), > $five_days_ahead->truncate( to => 'minute' ), > 'GetLatestAutoRenewDate should return +5 days if no_auto_renewal_after = 15 and date_due is 10 days before' >@@ -1118,7 +1108,7 @@ subtest "CanBookBeRenewed tests" => sub { > } > } > ); >- $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); >+ $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); > is( $latest_auto_renew_date->truncate( to => 'day' ), > $two_days_ahead->truncate( to => 'day' ), > 'GetLatestAutoRenewDate should return +2 days if no_auto_renewal_after_hard_limit is defined and not no_auto_renewal_after' >@@ -1135,7 +1125,7 @@ subtest "CanBookBeRenewed tests" => sub { > } > } > ); >- $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); >+ $latest_auto_renew_date = GetLatestAutoRenewDate( $renewing_borrowernumber, $item_to_auto_renew->itemnumber ); > is( $latest_auto_renew_date->truncate( to => 'day' ), > $two_days_ahead->truncate( to => 'day' ), > 'GetLatestAutoRenewDate should return +2 days if no_auto_renewal_after_hard_limit is < no_auto_renewal_after' >@@ -1602,11 +1592,11 @@ subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { > homebranch => $homebranch->{branchcode}, > holdingbranch => $holdingbranch->{branchcode}, > } >- )->unblessed; >+ ); > > set_userenv($holdingbranch); > >- my $issue = AddIssue( $patron_1->unblessed, $item->{barcode} ); >+ my $issue = AddIssue( $patron_1->unblessed, $item->barcode ); > is( ref($issue), 'Koha::Checkout', 'AddIssue should return a Koha::Checkout object' ); > > my ( $error, $question, $alerts ); >@@ -1619,16 +1609,16 @@ subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { > ok( $error->{UNKNOWN_BARCODE}, '"KohaIsAwesome" is not a valid barcode as expected.' ); > ## Can be issued from homebranch > set_userenv($homebranch); >- ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode ); > is( keys(%$error) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); > is( exists $question->{ISSUED_TO_ANOTHER}, 1, 'ISSUED_TO_ANOTHER must be set' ); > ## Can be issued from holdingbranch > set_userenv($holdingbranch); >- ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode ); > is( keys(%$error) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); > is( exists $question->{ISSUED_TO_ANOTHER}, 1, 'ISSUED_TO_ANOTHER must be set' ); > ## Can be issued from another branch >- ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode ); > is( keys(%$error) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); > is( exists $question->{ISSUED_TO_ANOTHER}, 1, 'ISSUED_TO_ANOTHER must be set' ); > >@@ -1636,18 +1626,18 @@ subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { > t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'holdingbranch' ); > ## Cannot be issued from homebranch > set_userenv($homebranch); >- ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode ); > is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); > is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); > is( $error->{branch_to_return}, $holdingbranch->{branchcode}, 'branch_to_return matched holdingbranch' ); > ## Can be issued from holdinbranch > set_userenv($holdingbranch); >- ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode ); > is( keys(%$error) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); > is( exists $question->{ISSUED_TO_ANOTHER}, 1, 'ISSUED_TO_ANOTHER must be set' ); > ## Cannot be issued from another branch > set_userenv($otherbranch); >- ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode ); > is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); > is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); > is( $error->{branch_to_return}, $holdingbranch->{branchcode}, 'branch_to_return matches holdingbranch' ); >@@ -1656,18 +1646,18 @@ subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { > t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'homebranch' ); > ## Can be issued from holdinbranch > set_userenv($homebranch); >- ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode ); > is( keys(%$error) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); > is( exists $question->{ISSUED_TO_ANOTHER}, 1, 'ISSUED_TO_ANOTHER must be set' ); > ## Cannot be issued from holdinbranch > set_userenv($holdingbranch); >- ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode ); > is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); > is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); > is( $error->{branch_to_return}, $homebranch->{branchcode}, 'branch_to_return matches homebranch' ); > ## Cannot be issued from holdinbranch > set_userenv($otherbranch); >- ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} ); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->barcode ); > is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) ); > is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' ); > is( $error->{branch_to_return}, $homebranch->{branchcode}, 'branch_to_return matches homebranch' ); >@@ -1689,12 +1679,12 @@ subtest 'AddIssue & AllowReturnToBranch' => sub { > homebranch => $homebranch->{branchcode}, > holdingbranch => $holdingbranch->{branchcode}, > } >- )->unblessed; >+ ); > > set_userenv($holdingbranch); > > my $ref_issue = 'Koha::Checkout'; >- my $issue = AddIssue( $patron_1, $item->{barcode} ); >+ my $issue = AddIssue( $patron_1, $item->barcode ); > > my ( $error, $question, $alerts ); > >@@ -1702,42 +1692,42 @@ subtest 'AddIssue & AllowReturnToBranch' => sub { > t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' ); > ## Can be issued from homebranch > set_userenv($homebranch); >- is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue, 'AllowReturnToBranch - anywhere | Can be issued from homebranch'); >- set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue >+ is ( ref( AddIssue( $patron_2, $item->barcode ) ), $ref_issue, 'AllowReturnToBranch - anywhere | Can be issued from homebranch'); >+ set_userenv($holdingbranch); AddIssue( $patron_1, $item->barcode ); # Reinsert the original issue > ## Can be issued from holdinbranch > set_userenv($holdingbranch); >- is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue, 'AllowReturnToBranch - anywhere | Can be issued from holdingbranch'); >- set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue >+ is ( ref( AddIssue( $patron_2, $item->barcode ) ), $ref_issue, 'AllowReturnToBranch - anywhere | Can be issued from holdingbranch'); >+ set_userenv($holdingbranch); AddIssue( $patron_1, $item->barcode ); # Reinsert the original issue > ## Can be issued from another branch > set_userenv($otherbranch); >- is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue, 'AllowReturnToBranch - anywhere | Can be issued from otherbranch'); >- set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue >+ is ( ref( AddIssue( $patron_2, $item->barcode ) ), $ref_issue, 'AllowReturnToBranch - anywhere | Can be issued from otherbranch'); >+ set_userenv($holdingbranch); AddIssue( $patron_1, $item->barcode ); # Reinsert the original issue > > # AllowReturnToBranch == holdinbranch > t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'holdingbranch' ); > ## Cannot be issued from homebranch > set_userenv($homebranch); >- is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '', 'AllowReturnToBranch - holdingbranch | Cannot be issued from homebranch'); >+ is ( ref( AddIssue( $patron_2, $item->barcode ) ), '', 'AllowReturnToBranch - holdingbranch | Cannot be issued from homebranch'); > ## Can be issued from holdingbranch > set_userenv($holdingbranch); >- is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue, 'AllowReturnToBranch - holdingbranch | Can be issued from holdingbranch'); >- set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue >+ is ( ref( AddIssue( $patron_2, $item->barcode ) ), $ref_issue, 'AllowReturnToBranch - holdingbranch | Can be issued from holdingbranch'); >+ set_userenv($holdingbranch); AddIssue( $patron_1, $item->barcode ); # Reinsert the original issue > ## Cannot be issued from another branch > set_userenv($otherbranch); >- is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '', 'AllowReturnToBranch - holdingbranch | Cannot be issued from otherbranch'); >+ is ( ref( AddIssue( $patron_2, $item->barcode ) ), '', 'AllowReturnToBranch - holdingbranch | Cannot be issued from otherbranch'); > > # AllowReturnToBranch == homebranch > t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'homebranch' ); > ## Can be issued from homebranch > set_userenv($homebranch); >- is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue, 'AllowReturnToBranch - homebranch | Can be issued from homebranch' ); >- set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue >+ is ( ref( AddIssue( $patron_2, $item->barcode ) ), $ref_issue, 'AllowReturnToBranch - homebranch | Can be issued from homebranch' ); >+ set_userenv($holdingbranch); AddIssue( $patron_1, $item->barcode ); # Reinsert the original issue > ## Cannot be issued from holdinbranch > set_userenv($holdingbranch); >- is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '', 'AllowReturnToBranch - homebranch | Cannot be issued from holdingbranch' ); >+ is ( ref( AddIssue( $patron_2, $item->barcode ) ), '', 'AllowReturnToBranch - homebranch | Cannot be issued from holdingbranch' ); > ## Cannot be issued from another branch > set_userenv($otherbranch); >- is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '', 'AllowReturnToBranch - homebranch | Cannot be issued from otherbranch' ); >+ is ( ref( AddIssue( $patron_2, $item->barcode ) ), '', 'AllowReturnToBranch - homebranch | Cannot be issued from otherbranch' ); > # TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch'); > }; > >@@ -1750,38 +1740,38 @@ subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { > { > library => $library->{branchcode}, > } >- )->unblessed; >+ ); > my $item_2 = $builder->build_sample_item( > { > library => $library->{branchcode}, > } >- )->unblessed; >+ ); > > my ( $error, $question, $alerts ); > > # Patron cannot issue item_1, they have overdues > my $yesterday = DateTime->today( time_zone => C4::Context->tz() )->add( days => -1 ); >- my $issue = AddIssue( $patron->unblessed, $item_1->{barcode}, $yesterday ); # Add an overdue >+ my $issue = AddIssue( $patron->unblessed, $item_1->barcode, $yesterday ); # Add an overdue > > t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'confirmation' ); >- ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); > is( keys(%$error) + keys(%$alerts), 0, 'No key for error and alert' . str($error, $question, $alerts) ); > is( $question->{USERBLOCKEDOVERDUE}, 1, 'OverduesBlockCirc=confirmation, USERBLOCKEDOVERDUE should be set for question' ); > > t::lib::Mocks::mock_preference( 'OverduesBlockCirc', 'block' ); >- ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); > is( keys(%$question) + keys(%$alerts), 0, 'No key for question and alert ' . str($error, $question, $alerts) ); > is( $error->{USERBLOCKEDOVERDUE}, 1, 'OverduesBlockCirc=block, USERBLOCKEDOVERDUE should be set for error' ); > > # Patron cannot issue item_1, they are debarred > my $tomorrow = DateTime->today( time_zone => C4::Context->tz() )->add( days => 1 ); > Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->borrowernumber, expiration => $tomorrow } ); >- ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); > is( keys(%$question) + keys(%$alerts), 0, 'No key for question and alert ' . str($error, $question, $alerts) ); > is( $error->{USERBLOCKEDWITHENDDATE}, output_pref( { dt => $tomorrow, dateformat => 'sql', dateonly => 1 } ), 'USERBLOCKEDWITHENDDATE should be tomorrow' ); > > Koha::Patron::Debarments::AddDebarment( { borrowernumber => $patron->borrowernumber } ); >- ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); > is( keys(%$question) + keys(%$alerts), 0, 'No key for question and alert ' . str($error, $question, $alerts) ); > is( $error->{USERBLOCKEDNOENDDATE}, '9999-12-31', 'USERBLOCKEDNOENDDATE should be 9999-12-31 for unlimited debarments' ); > }; >@@ -1812,9 +1802,9 @@ subtest 'CanBookBeIssued + Statistic patrons "X"' => sub { > { > library => $library->{branchcode}, > } >- )->unblessed; >+ ); > >- my ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_1->{barcode} ); >+ my ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_1->barcode ); > is( $error->{STATS}, 1, '"Error" flag "STATS" must be set if CanBookBeIssued is called with a statistic patron (category_type=X)' ); > > # TODO There are other tests to provide here >@@ -1944,20 +1934,20 @@ subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub { > biblionumber => $biblionumber, > library => $library->{branchcode}, > } >- )->unblessed; >+ ); > > my $item_2 = $builder->build_sample_item( > { > biblionumber => $biblionumber, > library => $library->{branchcode}, > } >- )->unblessed; >+ ); > > my ( $error, $question, $alerts ); >- my $issue = AddIssue( $patron->unblessed, $item_1->{barcode}, dt_from_string->add( days => 1 ) ); >+ my $issue = AddIssue( $patron->unblessed, $item_1->barcode, dt_from_string->add( days => 1 ) ); > > t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 0); >- ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); > cmp_deeply( > { error => $error, alerts => $alerts }, > { error => {}, alerts => {} }, >@@ -1966,7 +1956,7 @@ subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub { > is( $question->{BIBLIO_ALREADY_ISSUED}, 1, 'BIBLIO_ALREADY_ISSUED question flag should be set if AllowMultipleIssuesOnABiblio=0 and issue already exists' ); > > t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 1); >- ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); > cmp_deeply( > { error => $error, question => $question, alerts => $alerts }, > { error => {}, question => {}, alerts => {} }, >@@ -1977,7 +1967,7 @@ subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub { > Koha::Subscription->new({ biblionumber => $biblionumber })->store; > > t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 0); >- ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); > cmp_deeply( > { error => $error, question => $question, alerts => $alerts }, > { error => {}, question => {}, alerts => {} }, >@@ -1985,7 +1975,7 @@ subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub { > ); > > t::lib::Mocks::mock_preference('AllowMultipleIssuesOnABiblio', 1); >- ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->{barcode} ); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron, $item_2->barcode ); > cmp_deeply( > { error => $error, question => $question, alerts => $alerts }, > { error => {}, question => {}, alerts => {} }, >@@ -2010,13 +2000,13 @@ subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { > biblionumber => $biblionumber, > library => $library->{branchcode}, > } >- )->unblessed; >+ ); > my $item_2 = $builder->build_sample_item( > { > biblionumber => $biblionumber, > library => $library->{branchcode}, > } >- )->unblessed; >+ ); > > # And the circulation rule > Koha::CirculationRules->search->delete; >@@ -2038,12 +2028,12 @@ subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { > my $now = dt_from_string; > my $five_days_ago = $now->clone->subtract( days => 5 ); > my $ten_days_ago = $now->clone->subtract( days => 10 ); >- AddIssue( $patron, $item_1->{barcode}, $five_days_ago ); # Add an overdue >- AddIssue( $patron, $item_2->{barcode}, $ten_days_ago ) >+ AddIssue( $patron, $item_1->barcode, $five_days_ago ); # Add an overdue >+ AddIssue( $patron, $item_2->barcode, $ten_days_ago ) > ; # Add another overdue > > t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '0' ); >- AddReturn( $item_1->{barcode}, $library->{branchcode}, undef, $now ); >+ AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); > my $debarments = Koha::Patron::Debarments::GetDebarments( > { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); > is( scalar(@$debarments), 1 ); >@@ -2059,7 +2049,7 @@ subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { > ); > is( $debarments->[0]->{expiration}, $expected_expiration ); > >- AddReturn( $item_2->{barcode}, $library->{branchcode}, undef, $now ); >+ AddReturn( $item_2->barcode, $library->{branchcode}, undef, $now ); > $debarments = Koha::Patron::Debarments::GetDebarments( > { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); > is( scalar(@$debarments), 1 ); >@@ -2076,10 +2066,10 @@ subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { > { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); > > t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '1' ); >- AddIssue( $patron, $item_1->{barcode}, $five_days_ago ); # Add an overdue >- AddIssue( $patron, $item_2->{barcode}, $ten_days_ago ) >+ AddIssue( $patron, $item_1->barcode, $five_days_ago ); # Add an overdue >+ AddIssue( $patron, $item_2->barcode, $ten_days_ago ) > ; # Add another overdue >- AddReturn( $item_1->{barcode}, $library->{branchcode}, undef, $now ); >+ AddReturn( $item_1->barcode, $library->{branchcode}, undef, $now ); > $debarments = Koha::Patron::Debarments::GetDebarments( > { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); > is( scalar(@$debarments), 1 ); >@@ -2092,7 +2082,7 @@ subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { > ); > is( $debarments->[0]->{expiration}, $expected_expiration ); > >- AddReturn( $item_2->{barcode}, $library->{branchcode}, undef, $now ); >+ AddReturn( $item_2->barcode, $library->{branchcode}, undef, $now ); > $debarments = Koha::Patron::Debarments::GetDebarments( > { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } ); > is( scalar(@$debarments), 1 ); >@@ -2122,7 +2112,7 @@ subtest 'AddReturn + suspension_chargeperiod' => sub { > biblionumber => $biblionumber, > library => $library->{branchcode}, > } >- )->unblessed; >+ ); > > # And the issuing rule > Koha::CirculationRules->search->delete; >@@ -2336,17 +2326,17 @@ subtest 'CanBookBeIssued + AutoReturnCheckedOutItems' => sub { > { > library => $library->branchcode, > } >- )->unblessed; >+ ); > > my ( $error, $question, $alerts ); >- my $issue = AddIssue( $patron1->unblessed, $item->{barcode} ); >+ my $issue = AddIssue( $patron1->unblessed, $item->barcode ); > > t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0); >- ( $error, $question, $alerts ) = CanBookBeIssued( $patron2, $item->{barcode} ); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron2, $item->barcode ); > is( $question->{ISSUED_TO_ANOTHER}, 1, 'ISSUED_TO_ANOTHER question flag should be set if AutoReturnCheckedOutItems is disabled and item is checked out to another' ); > > t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 1); >- ( $error, $question, $alerts ) = CanBookBeIssued( $patron2, $item->{barcode} ); >+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron2, $item->barcode ); > is( $alerts->{RETURNED_FROM_ANOTHER}->{patron}->borrowernumber, $patron1->borrowernumber, 'RETURNED_FROM_ANOTHER alert flag should be set if AutoReturnCheckedOutItems is enabled and item is checked out to another' ); > > t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0); >@@ -2371,7 +2361,7 @@ subtest 'AddReturn | is_overdue' => sub { > library => $library->{branchcode}, > replacementprice => 7 > } >- )->unblessed; >+ ); > > Koha::CirculationRules->search->delete; > Koha::CirculationRules->set_rules( >@@ -2396,26 +2386,26 @@ subtest 'AddReturn | is_overdue' => sub { > $patron = Koha::Patrons->find( $patron->{borrowernumber} ); > > # No return date specified, today will be used => 10 days overdue charged >- AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago >- AddReturn( $item->{barcode}, $library->{branchcode} ); >+ AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); # date due was 10d ago >+ AddReturn( $item->barcode, $library->{branchcode} ); > is( int($patron->account->balance()), 10, 'Patron should have a charge of 10 (10 days x 1)' ); > Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; > > # specify return date 5 days before => no overdue charged >- AddIssue( $patron->unblessed, $item->{barcode}, $five_days_ago ); # date due was 5d ago >- AddReturn( $item->{barcode}, $library->{branchcode}, undef, $ten_days_ago ); >+ AddIssue( $patron->unblessed, $item->barcode, $five_days_ago ); # date due was 5d ago >+ AddReturn( $item->barcode, $library->{branchcode}, undef, $ten_days_ago ); > is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); > Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; > > # specify return date 5 days later => 5 days overdue charged >- AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago >- AddReturn( $item->{barcode}, $library->{branchcode}, undef, $five_days_ago ); >+ AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); # date due was 10d ago >+ AddReturn( $item->barcode, $library->{branchcode}, undef, $five_days_ago ); > is( int($patron->account->balance()), 5, 'AddReturn: pass return_date => overdue' ); > Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; > > # specify return date 5 days later, specify exemptfine => no overdue charge >- AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago >- AddReturn( $item->{barcode}, $library->{branchcode}, 1, $five_days_ago ); >+ AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); # date due was 10d ago >+ AddReturn( $item->barcode, $library->{branchcode}, 1, $five_days_ago ); > is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' ); > Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; > >@@ -2423,7 +2413,7 @@ subtest 'AddReturn | is_overdue' => sub { > > plan tests => 3; > >- my $issue = AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago >+ my $issue = AddIssue( $patron->unblessed, $item->barcode, $ten_days_ago ); # date due was 10d ago > > # Fake fines cronjob on this checkout > my ($fine) = >@@ -2432,7 +2422,7 @@ subtest 'AddReturn | is_overdue' => sub { > UpdateFine( > { > issue_id => $issue->issue_id, >- itemnumber => $item->{itemnumber}, >+ itemnumber => $item->itemnumber, > borrowernumber => $patron->borrowernumber, > amount => $fine, > due => output_pref($ten_days_ago) >@@ -2442,12 +2432,12 @@ subtest 'AddReturn | is_overdue' => sub { > 10, "Overdue fine of 10 days overdue" ); > > # Fake longoverdue with charge and not marking returned >- LostItem( $item->{itemnumber}, 'cronjob', 0 ); >+ LostItem( $item->itemnumber, 'cronjob', 0 ); > is( int( $patron->account->balance() ), > 17, "Lost fine of 7 plus 10 days overdue" ); > > # Now we return it today >- AddReturn( $item->{barcode}, $library->{branchcode} ); >+ AddReturn( $item->barcode, $library->{branchcode} ); > is( int( $patron->account->balance() ), > 17, "Should have a single 10 days overdue fine and lost charge" ); > >@@ -2461,7 +2451,7 @@ subtest 'AddReturn | is_overdue' => sub { > > t::lib::Mocks::mock_preference('CalculateFinesOnBackdate', 1); > >- my $issue = AddIssue( $patron->unblessed, $item->{barcode}, $one_day_ago ); # date due was 1d ago >+ my $issue = AddIssue( $patron->unblessed, $item->barcode, $one_day_ago ); # date due was 1d ago > > # Fake fines cronjob on this checkout > my ($fine) = >@@ -2470,7 +2460,7 @@ subtest 'AddReturn | is_overdue' => sub { > UpdateFine( > { > issue_id => $issue->issue_id, >- itemnumber => $item->{itemnumber}, >+ itemnumber => $item->itemnumber, > borrowernumber => $patron->borrowernumber, > amount => $fine, > due => output_pref($one_day_ago) >@@ -2480,13 +2470,13 @@ subtest 'AddReturn | is_overdue' => sub { > 1, "Overdue fine of 1 day overdue" ); > > # Backdated return (dropbox mode example - charge should be removed) >- AddReturn( $item->{barcode}, $library->{branchcode}, 1, $one_day_ago ); >+ AddReturn( $item->barcode, $library->{branchcode}, 1, $one_day_ago ); > is( int( $patron->account->balance() ), > 0, "Overdue fine should be annulled" ); > my $lines = Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber }); > is( $lines->count, 0, "Overdue fine accountline has been removed"); > >- $issue = AddIssue( $patron->unblessed, $item->{barcode}, $two_days_ago ); # date due was 2d ago >+ $issue = AddIssue( $patron->unblessed, $item->barcode, $two_days_ago ); # date due was 2d ago > > # Fake fines cronjob on this checkout > ($fine) = >@@ -2495,7 +2485,7 @@ subtest 'AddReturn | is_overdue' => sub { > UpdateFine( > { > issue_id => $issue->issue_id, >- itemnumber => $item->{itemnumber}, >+ itemnumber => $item->itemnumber, > borrowernumber => $patron->borrowernumber, > amount => $fine, > due => output_pref($one_day_ago) >@@ -2526,7 +2516,7 @@ subtest 'AddReturn | is_overdue' => sub { > is( $line->amountoutstanding+0, 0, "Overdue fine amountoutstanding reduced to 0"); > > # Backdated return (dropbox mode example - charge should be removed) >- AddReturn( $item->{barcode}, $library->{branchcode}, undef, $one_day_ago ); >+ AddReturn( $item->barcode, $library->{branchcode}, undef, $one_day_ago ); > is( int( $patron->account->balance() ), > -1, "Refund credit has been applied" ); > $lines = Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber }, { order_by => { '-asc' => 'accountlines_id' }}); >@@ -2553,7 +2543,7 @@ subtest 'AddReturn | is_overdue' => sub { > > t::lib::Mocks::mock_preference('CalculateFinesOnBackdate', 1); > >- my $issue = AddIssue( $patron->unblessed, $item->{barcode}, $one_day_ago ); # date due was 1d ago >+ my $issue = AddIssue( $patron->unblessed, $item->barcode, $one_day_ago ); # date due was 1d ago > > # Fake fines cronjob on this checkout > my ($fine) = >@@ -2562,7 +2552,7 @@ subtest 'AddReturn | is_overdue' => sub { > UpdateFine( > { > issue_id => $issue->issue_id, >- itemnumber => $item->{itemnumber}, >+ itemnumber => $item->itemnumber, > borrowernumber => $patron->borrowernumber, > amount => $fine, > due => output_pref($one_day_ago) >@@ -2572,7 +2562,7 @@ subtest 'AddReturn | is_overdue' => sub { > 1, "Overdue fine of 1 day overdue" ); > > # Backdated return (dropbox mode example - charge should no longer exist) >- AddReturn( $item->{barcode}, $library->{branchcode}, 1, $one_day_ago ); >+ AddReturn( $item->barcode, $library->{branchcode}, 1, $one_day_ago ); > is( int( $patron->account->balance() ), > 0, "Overdue fine should be annulled" ); > >@@ -2586,13 +2576,13 @@ subtest 'AddReturn | is_overdue' => sub { > t::lib::Mocks::mock_preference( 'CalculateFinesOnBackdate', 1 ); > > my $due_date = dt_from_string; >- my $issue = AddIssue( $patron->unblessed, $item->{barcode}, $due_date ); >+ my $issue = AddIssue( $patron->unblessed, $item->barcode, $due_date ); > > # Add fine > UpdateFine( > { > issue_id => $issue->issue_id, >- itemnumber => $item->{itemnumber}, >+ itemnumber => $item->itemnumber, > borrowernumber => $patron->borrowernumber, > amount => 0.25, > due => output_pref($due_date) >@@ -2603,7 +2593,7 @@ subtest 'AddReturn | is_overdue' => sub { > > # Backdate return to exact due date and time > my ( undef, $message ) = >- AddReturn( $item->{barcode}, $library->{branchcode}, >+ AddReturn( $item->barcode, $library->{branchcode}, > undef, $due_date ); > > my $accountline = >@@ -2611,13 +2601,13 @@ subtest 'AddReturn | is_overdue' => sub { > ok( !$accountline, 'accountline removed as expected' ); > > # Re-issue >- $issue = AddIssue( $patron->unblessed, $item->{barcode}, $due_date ); >+ $issue = AddIssue( $patron->unblessed, $item->barcode, $due_date ); > > # Add fine > UpdateFine( > { > issue_id => $issue->issue_id, >- itemnumber => $item->{itemnumber}, >+ itemnumber => $item->itemnumber, > borrowernumber => $patron->borrowernumber, > amount => .25, > due => output_pref($due_date) >@@ -2647,7 +2637,7 @@ subtest 'AddReturn | is_overdue' => sub { > > # Backdate return to exact due date and time > ( undef, $message ) = >- AddReturn( $item->{barcode}, $library->{branchcode}, >+ AddReturn( $item->barcode, $library->{branchcode}, > undef, $due_date ); > > $lines = Koha::Account::Lines->search( >@@ -2766,46 +2756,46 @@ subtest 'Set waiting flag' => sub { > { > library => $library_1->{branchcode}, > } >- )->unblessed; >+ ); > > set_userenv( $library_2 ); > my $reserve_id = AddReserve( > { > branchcode => $library_2->{branchcode}, > borrowernumber => $patron_2->{borrowernumber}, >- biblionumber => $item->{biblionumber}, >+ biblionumber => $item->biblionumber, > priority => 1, >- itemnumber => $item->{itemnumber}, >+ itemnumber => $item->itemnumber, > } > ); > > set_userenv( $library_1 ); > my $do_transfer = 1; >- my ( $res, $rr ) = AddReturn( $item->{barcode}, $library_1->{branchcode} ); >- ModReserveAffect( $item->{itemnumber}, undef, $do_transfer, $reserve_id ); >+ my ( $res, $rr ) = AddReturn( $item->barcode, $library_1->{branchcode} ); >+ ModReserveAffect( $item->itemnumber, undef, $do_transfer, $reserve_id ); > my $hold = Koha::Holds->find( $reserve_id ); > is( $hold->found, 'T', 'Hold is in transit' ); > >- my ( $status ) = CheckReserves($item->{itemnumber}); >+ my ( $status ) = CheckReserves($item->itemnumber); > is( $status, 'Reserved', 'Hold is not waiting yet'); > > set_userenv( $library_2 ); > $do_transfer = 0; >- AddReturn( $item->{barcode}, $library_2->{branchcode} ); >- ModReserveAffect( $item->{itemnumber}, undef, $do_transfer, $reserve_id ); >+ AddReturn( $item->barcode, $library_2->{branchcode} ); >+ ModReserveAffect( $item->itemnumber, undef, $do_transfer, $reserve_id ); > $hold = Koha::Holds->find( $reserve_id ); > is( $hold->found, 'W', 'Hold is waiting' ); >- ( $status ) = CheckReserves($item->{itemnumber}); >+ ( $status ) = CheckReserves($item->itemnumber); > is( $status, 'Waiting', 'Now the hold is waiting'); > > #Bug 21944 - Waiting transfer checked in at branch other than pickup location > set_userenv( $library_1 ); >- (undef, my $messages, undef, undef ) = AddReturn ( $item->{barcode}, $library_1->{branchcode} ); >+ (undef, my $messages, undef, undef ) = AddReturn ( $item->barcode, $library_1->{branchcode} ); > $hold = Koha::Holds->find( $reserve_id ); > is( $hold->found, undef, 'Hold is no longer marked waiting' ); > is( $hold->priority, 1, "Hold is now priority one again"); > is( $hold->waitingdate, undef, "Hold no longer has a waiting date"); >- is( $hold->itemnumber, $item->{itemnumber}, "Hold has retained its' itemnumber"); >+ is( $hold->itemnumber, $item->itemnumber, "Hold has retained its' itemnumber"); > is( $messages->{ResFound}->{ResFound}, "Reserved", "Hold is still returned"); > is( $messages->{ResFound}->{found}, undef, "Hold is no longer marked found in return message"); > is( $messages->{ResFound}->{priority}, 1, "Hold is priority 1 in return message"); >@@ -2898,12 +2888,12 @@ subtest 'CanBookBeIssued | is_overdue' => sub { > { > library => $library->{branchcode}, > } >- )->unblessed; >+ ); > >- my $issue = AddIssue( $patron->unblessed, $item->{barcode}, $five_days_go ); # date due was 10d ago >- my $actualissue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } ); >+ my $issue = AddIssue( $patron->unblessed, $item->barcode, $five_days_go ); # date due was 10d ago >+ my $actualissue = Koha::Checkouts->find( { itemnumber => $item->itemnumber } ); > is( output_pref({ str => $actualissue->date_due, dateonly => 1}), $five_days_go, "First issue works"); >- my ($issuingimpossible, $needsconfirmation) = CanBookBeIssued($patron,$item->{barcode},$ten_days_go, undef, undef, undef); >+ my ($issuingimpossible, $needsconfirmation) = CanBookBeIssued($patron,$item->barcode,$ten_days_go, undef, undef, undef); > is( $needsconfirmation->{RENEW_ISSUE}, 1, "This is a renewal"); > is( $needsconfirmation->{TOO_MANY}, undef, "Not too many, is a renewal"); > }; >@@ -3524,20 +3514,13 @@ subtest 'CanBookBeIssued & RentalFeesCheckoutConfirmation' => sub { > } > ); > >- my $biblioitem = $builder->build( { source => 'Biblioitem' } ); >- my $item = $builder->build_object( >+ my $item = $builder->build_sample_item( > { >- class => 'Koha::Items', >- value => { >- homebranch => $library->id, >- holdingbranch => $library->id, >- notforloan => 0, >- itemlost => 0, >- withdrawn => 0, >- itype => $itemtype->id, >- biblionumber => $biblioitem->{biblionumber}, >- biblioitemnumber => $biblioitem->{biblioitemnumber}, >- } >+ library => $library->id, >+ notforloan => 0, >+ itemlost => 0, >+ withdrawn => 0, >+ itype => $itemtype->id, > } > )->store; > >diff --git a/t/db_dependent/Circulation/CalcFine.t b/t/db_dependent/Circulation/CalcFine.t >index f09a0e011d..85f38ea42e 100644 >--- a/t/db_dependent/Circulation/CalcFine.t >+++ b/t/db_dependent/Circulation/CalcFine.t >@@ -44,15 +44,6 @@ my $patron = $builder->build( > } > ); > >-my $biblio = $builder->build( >- { >- source => 'Biblio', >- value => { >- branchcode => $branch->{branchcode}, >- }, >- } >-); >- > my $itemtype = $builder->build( > { > source => 'Itemtype', >@@ -62,16 +53,11 @@ my $itemtype = $builder->build( > } > ); > >-my $item = $builder->build( >+my $item = $builder->build_sample_item( > { >- source => 'Item', >- value => { >- biblionumber => $biblio->{biblionumber}, >- homebranch => $branch->{branchcode}, >- holdingbranch => $branch->{branchcode}, >- replacementprice => '5.00', >- itype => $itemtype->{itemtype}, >- }, >+ library => $branch->{branchcode}, >+ replacementprice => '5.00', >+ itype => $itemtype->{itemtype}, > } > ); > >@@ -107,7 +93,7 @@ subtest 'Test basic functionality' => sub { > day => 30, > ); > >- my ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt ); >+ my ($amount) = CalcFine( $item->unblessed, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt ); > > is( $amount, 29, 'Amount is calculated correctly' ); > >@@ -147,15 +133,21 @@ subtest 'Test cap_fine_to_replacement_price' => sub { > day => 30, > ); > >- my ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt ); >+ my $item = $builder->build_sample_item( >+ { >+ library => $branch->{branchcode}, >+ replacementprice => 5, >+ itype => $itemtype->{itemtype}, >+ } >+ ); > >- is( int($amount), 5, 'Amount is calculated correctly' ); >+ my ($amount) = CalcFine( $item->unblessed, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt ); > >+ is( int($amount), 5, 'Amount is calculated correctly' ); > > # Use default replacement cost (useDefaultReplacementCost) is item's replacement price is 0 >- my $item_obj = Koha::Items->find($item->{itemnumber}); >- $item_obj->replacementprice(0)->store; >- ($amount) = CalcFine( $item_obj->unblessed, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt ); >+ $item->replacementprice(0)->store; >+ ($amount) = CalcFine( $item->unblessed, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt ); > is( int($amount), 6, 'Amount is calculated correctly' ); > > teardown(); >@@ -194,11 +186,11 @@ subtest 'Test cap_fine_to_replacement_pricew with overduefinescap' => sub { > day => 30, > ); > >- my ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt ); >+ my ($amount) = CalcFine( $item->unblessed, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt ); > is( int($amount), 3, 'Got the lesser of overduefinescap and replacement price where overduefinescap < replacement price' ); > > Koha::CirculationRules->set_rule({ rule_name => 'overduefinescap', rule_value => 6, branchcode => undef, categorycode => undef, itemtype => undef }); >- ($amount) = CalcFine( $item, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt ); >+ ($amount) = CalcFine( $item->unblessed, $patron->{categorycode}, $branch->{branchcode}, $start_dt, $end_dt ); > is( int($amount), 5, 'Get the lesser of overduefinescap and replacement price where overduefinescap > replacement price' ); > > teardown(); >diff --git a/t/db_dependent/Circulation/MarkIssueReturned.t b/t/db_dependent/Circulation/MarkIssueReturned.t >index 4ff85a9ae4..e9152d3f9f 100644 >--- a/t/db_dependent/Circulation/MarkIssueReturned.t >+++ b/t/db_dependent/Circulation/MarkIssueReturned.t >@@ -48,17 +48,9 @@ subtest 'Failure tests' => sub { > value => { branchcode => $library->branchcode, categorycode => $category->categorycode } > } > ); >- my $biblioitem = $builder->build_object( { class => 'Koha::Biblioitems' } ); >- my $item = $builder->build_object( >- { class => 'Koha::Items', >- value => { >- homebranch => $library->branchcode, >- holdingbranch => $library->branchcode, >- notforloan => 0, >- itemlost => 0, >- withdrawn => 0, >- biblionumber => $biblioitem->biblionumber, >- } >+ my $item = $builder->build_sample_item( >+ { >+ library => $library->branchcode, > } > ); > >@@ -95,17 +87,9 @@ subtest 'Anonymous patron tests' => sub { > value => { branchcode => $library->branchcode, categorycode => $category->categorycode } > } > ); >- my $biblioitem = $builder->build_object( { class => 'Koha::Biblioitems' } ); >- my $item = $builder->build_object( >- { class => 'Koha::Items', >- value => { >- homebranch => $library->branchcode, >- holdingbranch => $library->branchcode, >- notforloan => 0, >- itemlost => 0, >- withdrawn => 0, >- biblionumber => $biblioitem->biblionumber, >- } >+ my $item = $builder->build_sample_item( >+ { >+ library => $library->branchcode, > } > ); > >@@ -149,17 +133,9 @@ subtest 'Manually pass a return date' => sub { > value => { branchcode => $library->branchcode, categorycode => $category->categorycode } > } > ); >- my $biblioitem = $builder->build_object( { class => 'Koha::Biblioitems' } ); >- my $item = $builder->build_object( >- { class => 'Koha::Items', >- value => { >- homebranch => $library->branchcode, >- holdingbranch => $library->branchcode, >- notforloan => 0, >- itemlost => 0, >- withdrawn => 0, >- biblionumber => $biblioitem->biblionumber, >- } >+ my $item = $builder->build_sample_item( >+ { >+ library => $library->branchcode, > } > ); > >diff --git a/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t b/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t >index 341ecd7756..4746cb8ae1 100644 >--- a/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t >+++ b/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t >@@ -33,16 +33,7 @@ $schema->storage->txn_begin; > > my $builder = t::lib::TestBuilder->new(); > >-my $item = $builder->build( >- { >- source => 'Item', >- value => { >- biblionumber => $builder->build( { source => 'Biblioitem' } )->{biblionumber}, >- notforloan => 0, >- withdrawn => 0 >- } >- } >-); >+my $item = $builder->build_sample_item; > > my $patron_category = $builder->build({ source => 'Category', value => { categorycode => 'NOT_X', category_type => 'P', enrolmentfee => 0 } }); > my $patron = $builder->build_object( >@@ -77,12 +68,12 @@ my $r = $builder->build_object( > t::lib::Mocks::mock_preference( 'NoIssuesChargeGuarantees', '5.00' ); > t::lib::Mocks::mock_preference( 'AllowFineOverride', '' ); > >-my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->{barcode} ); >+my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode ); > is( $issuingimpossible->{DEBT_GUARANTEES}, undef, "Patron can check out item" ); > > my $account = Koha::Account->new( { patron_id => $guarantee->id } ); > $account->add_debit({ amount => 10.00, type => 'LOST', interface => 'test' }); >-( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->{barcode} ); >+( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode ); > is( $issuingimpossible->{DEBT_GUARANTEES} + 0, '10.00' + 0, "Patron cannot check out item due to debt for guarantee" ); > > my $accountline = Koha::Account::Lines->search({ borrowernumber => $guarantee->id })->next(); >diff --git a/t/db_dependent/Circulation/ReturnClaims.t b/t/db_dependent/Circulation/ReturnClaims.t >index 464420ead2..7d3b52128e 100644 >--- a/t/db_dependent/Circulation/ReturnClaims.t >+++ b/t/db_dependent/Circulation/ReturnClaims.t >@@ -62,18 +62,7 @@ subtest 'Test Koha::Checkout::claim_returned' => sub { > plan tests => 6; > > t::lib::Mocks::mock_preference( 'ClaimReturnedLostValue', 1 ); >- my $biblio = $builder->build_object( { class => 'Koha::Biblios' } ); >- my $item = $builder->build_object( >- { >- class => 'Koha::Items', >- value => { >- biblionumber => $biblio->biblionumber, >- notforloan => 0, >- itemlost => 0, >- withdrawn => 0, >- } >- } >- ); >+ my $item = $builder->build_sample_item; > my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); > my $checkout = AddIssue( $patron->unblessed, $item->barcode ); > >@@ -96,18 +85,7 @@ subtest 'Test Koha::Patronn::return_claims' => sub { > plan tests => 7; > > t::lib::Mocks::mock_preference( 'ClaimReturnedLostValue', 1 ); >- my $biblio = $builder->build_object( { class => 'Koha::Biblios' } ); >- my $item = $builder->build_object( >- { >- class => 'Koha::Items', >- value => { >- biblionumber => $biblio->biblionumber, >- notforloan => 0, >- itemlost => 0, >- withdrawn => 0, >- } >- } >- ); >+ my $item = $builder->build_sample_item; > my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); > my $checkout = AddIssue( $patron->unblessed, $item->barcode ); > >diff --git a/t/db_dependent/Circulation/Returns.t b/t/db_dependent/Circulation/Returns.t >index 5f3576a283..79ae8555bf 100644 >--- a/t/db_dependent/Circulation/Returns.t >+++ b/t/db_dependent/Circulation/Returns.t >@@ -104,53 +104,42 @@ subtest "AddReturn logging on statistics table (item-level_itypes=1)" => sub { > MARC::Field->new($tagfield,'','', $tagsubfield => $blevel_itemtype ) > ); > my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, '' ); >- my $item_with_itemtype = $builder->build( >+ my $item_with_itemtype = $builder->build_sample_item( > { >- source => 'Item', >- value => { >- biblionumber => $biblionumber, >- biblioitemnumber => $biblioitemnumber, >- homebranch => $branch, >- holdingbranch => $branch, >- itype => $ilevel_itemtype >- } >+ biblionumber => $biblionumber, >+ library => $branch, >+ itype => $ilevel_itemtype > } > ); >- my $item_without_itemtype = $builder->build( >+ my $item_without_itemtype = $builder->build_sample_item( > { >- source => 'Item', >- value => { >- biblionumber => $biblionumber, >- biblioitemnumber => $biblioitemnumber, >- homebranch => $branch, >- holdingbranch => $branch, >- itype => undef >- } >+ biblionumber => $biblionumber, >+ library => $branch, > } >- ); >+ )->_result->update({ itype => undef }); > > my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed; >- AddIssue( $borrower, $item_with_itemtype->{ barcode } ); >- AddReturn( $item_with_itemtype->{ barcode }, $branch ); >+ AddIssue( $borrower, $item_with_itemtype->barcode ); >+ AddReturn( $item_with_itemtype->barcode, $branch ); > # Test item-level itemtype was recorded on the 'statistics' table > my $stat = $schema->resultset('Statistic')->search({ > branch => $branch, > type => 'return', >- itemnumber => $item_with_itemtype->{ itemnumber } >+ itemnumber => $item_with_itemtype->itemnumber > }, { order_by => { -asc => 'datetime' } })->next(); > > is( $stat->itemtype, $ilevel_itemtype, > "item-level itype recorded on statistics for return"); >- warning_like { AddIssue( $borrower, $item_without_itemtype->{ barcode } ) } >+ warning_like { AddIssue( $borrower, $item_without_itemtype->barcode ) } > [qr/^item-level_itypes set but no itemtype set for item/, > qr/^item-level_itypes set but no itemtype set for item/], > 'Item without itemtype set raises warning on AddIssue'; >- AddReturn( $item_without_itemtype->{ barcode }, $branch ); >+ AddReturn( $item_without_itemtype->barcode, $branch ); > # Test biblio-level itemtype was recorded on the 'statistics' table > $stat = $schema->resultset('Statistic')->search({ > branch => $branch, > type => 'return', >- itemnumber => $item_without_itemtype->{ itemnumber } >+ itemnumber => $item_without_itemtype->itemnumber > }, { order_by => { -asc => 'datetime' } })->next(); > > is( $stat->itemtype, $blevel_itemtype, >@@ -194,48 +183,42 @@ subtest "AddReturn logging on statistics table (item-level_itypes=0)" => sub { > MARC::Field->new($tagfield,'','', $tagsubfield => $blevel_itemtype ) > ); > my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, '' ); >- my $item_with_itemtype = $builder->build({ >- source => 'Item', >- value => { >- biblionumber => $biblionumber, >- biblioitemnumber => $biblioitemnumber, >- homebranch => $branch, >- holdingbranch => $branch, >- itype => $ilevel_itemtype >+ my $item_with_itemtype = $builder->build_sample_item( >+ { >+ biblionumber => $biblionumber, >+ library => $branch, >+ itype => $ilevel_itemtype > } >- }); >- my $item_without_itemtype = $builder->build({ >- source => 'Item', >- value => { >- biblionumber => $biblionumber, >- biblioitemnumber => $biblioitemnumber, >- homebranch => $branch, >- holdingbranch => $branch, >- itype => undef >+ ); >+ my $item_without_itemtype = $builder->build_sample_item( >+ { >+ biblionumber => $biblionumber, >+ library => $branch, >+ itype => undef > } >- }); >+ ); > > my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed; > >- AddIssue( $borrower, $item_with_itemtype->{ barcode } ); >- AddReturn( $item_with_itemtype->{ barcode }, $branch ); >+ AddIssue( $borrower, $item_with_itemtype->barcode ); >+ AddReturn( $item_with_itemtype->barcode, $branch ); > # Test item-level itemtype was recorded on the 'statistics' table > my $stat = $schema->resultset('Statistic')->search({ > branch => $branch, > type => 'return', >- itemnumber => $item_with_itemtype->{ itemnumber } >+ itemnumber => $item_with_itemtype->itemnumber > }, { order_by => { -asc => 'datetime' } })->next(); > > is( $stat->itemtype, $blevel_itemtype, > "biblio-level itype recorded on statistics for return"); > >- AddIssue( $borrower, $item_without_itemtype->{ barcode } ); >- AddReturn( $item_without_itemtype->{ barcode }, $branch ); >+ AddIssue( $borrower, $item_without_itemtype->barcode ); >+ AddReturn( $item_without_itemtype->barcode, $branch ); > # Test biblio-level itemtype was recorded on the 'statistics' table > $stat = $schema->resultset('Statistic')->search({ > branch => $branch, > type => 'return', >- itemnumber => $item_without_itemtype->{ itemnumber } >+ itemnumber => $item_without_itemtype->itemnumber > }, { order_by => { -asc => 'datetime' } })->next(); > > is( $stat->itemtype, $blevel_itemtype, >@@ -261,24 +244,16 @@ subtest 'Handle ids duplication' => sub { > } > ); > >- my $biblio = $builder->build( { source => 'Biblio' } ); > my $itemtype = $builder->build( { source => 'Itemtype', value => { rentalcharge => 5 } } ); >- my $item = $builder->build( >+ my $item = $builder->build_sample_item( > { >- source => 'Item', >- value => { >- biblionumber => $biblio->{biblionumber}, >- notforloan => 0, >- itemlost => 0, >- withdrawn => 0, >- itype => $itemtype->{itemtype}, >- } >+ itype => $itemtype->{itemtype}, > } > ); > my $patron = $builder->build({source => 'Borrower'}); > $patron = Koha::Patrons->find( $patron->{borrowernumber} ); > >- my $original_checkout = AddIssue( $patron->unblessed, $item->{barcode}, dt_from_string->subtract( days => 50 ) ); >+ my $original_checkout = AddIssue( $patron->unblessed, $item->barcode, dt_from_string->subtract( days => 50 ) ); > my $issue_id = $original_checkout->issue_id; > my $account_lines = Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber, issue_id => $issue_id }); > is( $account_lines->count, 1, '1 account line should exist for this issue_id' ); >@@ -293,7 +268,7 @@ subtest 'Handle ids duplication' => sub { > my ($doreturn, $messages, $new_checkout, $borrower); > warning_like { > ( $doreturn, $messages, $new_checkout, $borrower ) = >- AddReturn( $item->{barcode}, undef, undef, undef, dt_from_string ); >+ AddReturn( $item->barcode, undef, undef, undef, dt_from_string ); > } > [ > qr{.*DBD::mysql::st execute failed: Duplicate entry.*}, >@@ -313,18 +288,7 @@ subtest 'Handle ids duplication' => sub { > > subtest 'BlockReturnOfLostItems' => sub { > plan tests => 4; >- my $biblio = $builder->build_object( { class => 'Koha::Biblios' } ); >- my $item = $builder->build_object( >- { >- class => 'Koha::Items', >- value => { >- biblionumber => $biblio->biblionumber, >- notforloan => 0, >- itemlost => 0, >- withdrawn => 0, >- } >- } >- ); >+ my $item = $builder->build_sample_item; > my $patron = $builder->build_object({class => 'Koha::Patrons'}); > my $checkout = AddIssue( $patron->unblessed, $item->barcode ); > >@@ -348,18 +312,7 @@ subtest 'Checkin of an item claimed as returned should generate a message' => su > plan tests => 1; > > t::lib::Mocks::mock_preference('ClaimReturnedLostValue', 1); >- my $biblio = $builder->build_object( { class => 'Koha::Biblios' } ); >- my $item = $builder->build_object( >- { >- class => 'Koha::Items', >- value => { >- biblionumber => $biblio->biblionumber, >- notforloan => 0, >- itemlost => 0, >- withdrawn => 0, >- } >- } >- ); >+ my $item = $builder->build_sample_item; > my $patron = $builder->build_object({class => 'Koha::Patrons'}); > my $checkout = AddIssue( $patron->unblessed, $item->barcode ); > >@@ -376,18 +329,7 @@ subtest 'BranchTransferLimitsType' => sub { > t::lib::Mocks::mock_preference('UseBranchTransferLimits', 1); > t::lib::Mocks::mock_preference('BranchTransferLimitsType', 'ccode'); > >- my $biblio = $builder->build_object( { class => 'Koha::Biblios' } ); >- my $item = $builder->build_object( >- { >- class => 'Koha::Items', >- value => { >- biblionumber => $biblio->biblionumber, >- notforloan => 0, >- itemlost => 0, >- withdrawn => 0, >- } >- } >- ); >+ my $item = $builder->build_sample_item; > my $patron = $builder->build_object({class => 'Koha::Patrons'}); > my $checkout = AddIssue( $patron->unblessed, $item->barcode ); > my ( $doreturn, $messages, $issue ) = AddReturn($item->barcode); >@@ -406,17 +348,7 @@ subtest 'Backdated returns should reduce fine if needed' => sub { > t::lib::Mocks::mock_preference( "CalculateFinesOnBackdate", 1 ); > > my $biblio = $builder->build_object( { class => 'Koha::Biblios' } ); >- my $item = $builder->build_object( >- { >- class => 'Koha::Items', >- value => { >- biblionumber => $biblio->biblionumber, >- notforloan => 0, >- itemlost => 0, >- withdrawn => 0, >- } >- } >- ); >+ my $item = $builder->build_sample_item; > my $patron = $builder->build_object({class => 'Koha::Patrons'}); > my $checkout = AddIssue( $patron->unblessed, $item->barcode ); > my $fine = Koha::Account::Line->new({ >diff --git a/t/db_dependent/Circulation/StoreLastBorrower.t b/t/db_dependent/Circulation/StoreLastBorrower.t >index 37f2c7e736..7d9440db39 100644 >--- a/t/db_dependent/Circulation/StoreLastBorrower.t >+++ b/t/db_dependent/Circulation/StoreLastBorrower.t >@@ -45,34 +45,26 @@ subtest 'Test StoreLastBorrower' => sub { > } > ); > >- my $item = $builder->build( >- { >- source => 'Item', >- value => { >- itemlost => 0, >- withdrawn => 0, >- }, >- } >- ); >+ my $item = $builder->build_sample_item; > > my $issue = $builder->build( > { > source => 'Issue', > value => { > borrowernumber => $patron->{borrowernumber}, >- itemnumber => $item->{itemnumber}, >+ itemnumber => $item->itemnumber, > }, > } > ); > >- my $item_object = Koha::Items->find( $item->{itemnumber} ); >- my $patron_object = $item_object->last_returned_by(); >+ $item = $item->get_from_storage; >+ my $patron_object = $item->last_returned_by(); > is( $patron_object, undef, 'Koha::Item::last_returned_by returned undef' ); > >- my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, $patron->{branchcode}, undef, dt_from_string('2010-10-10') ); >+ my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->barcode, $patron->{branchcode}, undef, dt_from_string('2010-10-10') ); > >- $item_object = Koha::Items->find( $item->{itemnumber} ); >- $patron_object = $item_object->last_returned_by(); >+ $item = $item->get_from_storage; >+ $patron_object = $item->last_returned_by(); > is( ref($patron_object), 'Koha::Patron', 'Koha::Item::last_returned_by returned Koha::Patron' ); > > $patron = $builder->build( >@@ -87,15 +79,15 @@ subtest 'Test StoreLastBorrower' => sub { > source => 'Issue', > value => { > borrowernumber => $patron->{borrowernumber}, >- itemnumber => $item->{itemnumber}, >+ itemnumber => $item->itemnumber, > }, > } > ); > >- ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, $patron->{branchcode}, undef, dt_from_string('2010-10-10') ); >+ ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->barcode, $patron->{branchcode}, undef, dt_from_string('2010-10-10') ); > >- $item_object = Koha::Items->find( $item->{itemnumber} ); >- $patron_object = $item_object->last_returned_by(); >+ $item = $item->get_from_storage; >+ $patron_object = $item->last_returned_by(); > is( $patron_object->id, $patron->{borrowernumber}, 'Second patron to return item replaces the first' ); > > $patron = $builder->build( >@@ -106,15 +98,15 @@ subtest 'Test StoreLastBorrower' => sub { > ); > $patron_object = Koha::Patrons->find( $patron->{borrowernumber} ); > >- $item_object->last_returned_by($patron_object); >- $item_object = Koha::Items->find( $item->{itemnumber} ); >- my $patron_object2 = $item_object->last_returned_by(); >+ $item->last_returned_by($patron_object); >+ $item = $item->get_from_storage; >+ my $patron_object2 = $item->last_returned_by(); > is( $patron_object->id, $patron_object2->id, > 'Calling last_returned_by with Borrower object sets last_returned_by to that borrower' ); > > $patron_object->delete; >- $item_object = Koha::Items->find( $item->{itemnumber} ); >- is( $item_object->last_returned_by, undef, 'last_returned_by should return undef if the last patron to return the item has been deleted' ); >+ $item = $item->get_from_storage; >+ is( $item->last_returned_by, undef, 'last_returned_by should return undef if the last patron to return the item has been deleted' ); > > t::lib::Mocks::mock_preference( 'StoreLastBorrower', '0' ); > $patron = $builder->build( >@@ -129,14 +121,14 @@ subtest 'Test StoreLastBorrower' => sub { > source => 'Issue', > value => { > borrowernumber => $patron->{borrowernumber}, >- itemnumber => $item->{itemnumber}, >+ itemnumber => $item->itemnumber, > }, > } > ); >- ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, $patron->{branchcode}, undef, dt_from_string('2010-10-10') ); >+ ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->barcode, $patron->{branchcode}, undef, dt_from_string('2010-10-10') ); > >- $item_object = Koha::Items->find( $item->{itemnumber} ); >- is( $item_object->last_returned_by, undef, 'Last patron to return item should not be stored if StoreLastBorrower if off' ); >+ $item = $item->get_from_storage; >+ is( $item->last_returned_by, undef, 'Last patron to return item should not be stored if StoreLastBorrower if off' ); > }; > > $schema->storage->txn_rollback; >diff --git a/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t b/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t >index 779c19d84e..9abe3bdc8e 100644 >--- a/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t >+++ b/t/db_dependent/Circulation/SwitchOnSiteCheckouts.t >@@ -57,29 +57,11 @@ my $patron = $builder->build_object({ > }); > my $patron_unblessed = $patron->unblessed; > >-my $biblio = $builder->build({ >- source => 'Biblio', >- value => { >- branchcode => $branch->{branchcode}, >- }, >-}); >-$builder->build( >+my $item = $builder->build_sample_item( > { >- source => 'Biblioitem', >- value => { biblionumber => $biblio->{biblionumber} } >+ library => $branch->{branchcode}, > } > ); >-my $item = $builder->build({ >- source => 'Item', >- value => { >- biblionumber => $biblio->{biblionumber}, >- homebranch => $branch->{branchcode}, >- holdingbranch => $branch->{branchcode}, >- notforloan => 0, >- withdrawn => 0, >- lost => 0, >- }, >-}); > > Koha::CirculationRules->search()->delete(); > Koha::CirculationRules->set_rules( >@@ -103,54 +85,45 @@ t::lib::Mocks::mock_userenv({ patron => $patron }); > t::lib::Mocks::mock_preference('AllowTooManyOverride', 0); > > # Add onsite checkout >-C4::Circulation::AddIssue( $patron_unblessed, $item->{barcode}, dt_from_string, undef, dt_from_string, undef, { onsite_checkout => 1 } ); >+C4::Circulation::AddIssue( $patron_unblessed, $item->barcode, dt_from_string, undef, dt_from_string, undef, { onsite_checkout => 1 } ); > > my ( $impossible, $messages ); > t::lib::Mocks::mock_preference('SwitchOnSiteCheckouts', 0); >-( $impossible, undef, undef, $messages ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} ); >+( $impossible, undef, undef, $messages ) = C4::Circulation::CanBookBeIssued( $patron, $item->barcode ); > is( $impossible->{NO_RENEWAL_FOR_ONSITE_CHECKOUTS}, 1, 'Do not renew on-site checkouts' ); > > t::lib::Mocks::mock_preference('SwitchOnSiteCheckouts', 1); >-( $impossible, undef, undef, $messages ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} ); >+( $impossible, undef, undef, $messages ) = C4::Circulation::CanBookBeIssued( $patron, $item->barcode ); > is( $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}, 1, 'If SwitchOnSiteCheckouts, switch the on-site checkout' ); > is( exists $impossible->{TOO_MANY}, '', 'If SwitchOnSiteCheckouts, switch the on-site checkout' ); >-C4::Circulation::AddIssue( $patron_unblessed, $item->{barcode}, undef, undef, undef, undef, { switch_onsite_checkout => 1 } ); >-my $issue = Koha::Checkouts->find( { itemnumber => $item->{itemnumber} } ); >+C4::Circulation::AddIssue( $patron_unblessed, $item->barcode, undef, undef, undef, undef, { switch_onsite_checkout => 1 } ); >+my $issue = Koha::Checkouts->find( { itemnumber => $item->itemnumber } ); > is( $issue->onsite_checkout, 0, 'The issue should have been switched to a regular checkout' ); > my $five_days_after = dt_from_string->add( days => 5 )->set( hour => 23, minute => 59, second => 0 ); > is( dt_from_string($issue->date_due, 'sql'), $five_days_after, 'The date_due should have been set depending on the circ rules when the on-site checkout has been switched' ); > > # Specific case > t::lib::Mocks::mock_preference('ConsiderOnSiteCheckoutsAsNormalCheckouts', 1); >-my $another_item = $builder->build({ >- source => 'Item', >- value => { >- biblionumber => $biblio->{biblionumber}, >- homebranch => $branch->{branchcode}, >- holdingbranch => $branch->{branchcode}, >- notforloan => 0, >- withdrawn => 0, >- lost => 0, >- }, >-}); >+my $another_item = $builder->build_sample_item( >+ { >+ biblionumber => $item->biblionumber, >+ library => $branch->{branchcode}, >+ } >+); > >-C4::Circulation::AddIssue( $patron_unblessed, $another_item->{barcode}, dt_from_string, undef, dt_from_string, undef, { onsite_checkout => 1 } ); >-( $impossible, undef, undef, $messages ) = C4::Circulation::CanBookBeIssued( $patron, $another_item->{barcode} ); >+C4::Circulation::AddIssue( $patron_unblessed, $another_item->barcode, dt_from_string, undef, dt_from_string, undef, { onsite_checkout => 1 } ); >+( $impossible, undef, undef, $messages ) = C4::Circulation::CanBookBeIssued( $patron, $another_item->barcode ); > is( $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}, 1, 'Specific case 1 - Switch is allowed' ); > is( exists $impossible->{TOO_MANY}, '', 'Specific case 1 - Switch is allowed' ); > >-my $yet_another_item = $builder->build({ >- source => 'Item', >- value => { >- biblionumber => $biblio->{biblionumber}, >- homebranch => $branch->{branchcode}, >- holdingbranch => $branch->{branchcode}, >- notforloan => 0, >- withdrawn => 0, >- lost => 0, >- }, >-}); >-( $impossible, undef, undef, undef ) = C4::Circulation::CanBookBeIssued( $patron, $yet_another_item->{barcode} ); >+my $yet_another_item = $builder->build_sample_item( >+ { >+ biblionumber => $item->biblionumber, >+ library => $branch->{branchcode}, >+ } >+); >+ >+( $impossible, undef, undef, undef ) = C4::Circulation::CanBookBeIssued( $patron, $yet_another_item->barcode ); > is( $impossible->{TOO_MANY}, 'TOO_MANY_CHECKOUTS', 'Not a specific case, $delta should not be incremented' ); > > Koha::CirculationRules->search()->delete(); >@@ -165,7 +138,7 @@ Koha::CirculationRules->set_rules( > } > } > ); >-( $impossible, undef, undef, $messages ) = C4::Circulation::CanBookBeIssued( $patron, $another_item->{barcode} ); >+( $impossible, undef, undef, $messages ) = C4::Circulation::CanBookBeIssued( $patron, $another_item->barcode ); > is( $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}, 1, 'Specific case 2 - Switch is allowed' ); > is( exists $impossible->{TOO_MANY}, '', 'Specific case 2 - Switch is allowed' ); > >diff --git a/t/db_dependent/Circulation/dateexpiry.t b/t/db_dependent/Circulation/dateexpiry.t >index c5b3db5a50..ca25f75254 100644 >--- a/t/db_dependent/Circulation/dateexpiry.t >+++ b/t/db_dependent/Circulation/dateexpiry.t >@@ -46,7 +46,7 @@ subtest 'Tests for CalcDateDue related to dateexpiry' => sub { > }; > > sub can_book_be_issued { >- my $item = $builder->build( { source => 'Item', value => { biblionumber => $builder->build( { source => 'Biblioitem' } )->{biblionumber} } } ); >+ my $item = $builder->build_sample_item; > my $patron = $builder->build_object( > { class => 'Koha::Patrons', > value => { >@@ -56,12 +56,12 @@ sub can_book_be_issued { > } > ); > my $duration = gettimeofday(); >- my ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} ); >+ my ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $item->barcode ); > $duration = gettimeofday() - $duration; > cmp_ok $duration, '<', 1, "CanBookBeIssued should not be take more than 1s if the patron is expired"; > is( not( exists $issuingimpossible->{EXPIRED} ), 1, 'The patron should not be considered as expired if dateexpiry is 9999-*' ); > >- $item = $builder->build( { source => 'Item', value => { biblionumber => $builder->build( { source => 'Biblioitem' } )->{biblionumber} } } ); >+ $item = $builder->build_sample_item; > $patron = $builder->build_object( > { class => 'Koha::Patrons', > value => { >@@ -70,11 +70,11 @@ sub can_book_be_issued { > } > } > ); >- ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} ); >+ ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $item->barcode ); > is( not( exists $issuingimpossible->{EXPIRED} ), 1, 'The patron should not be considered as expired if dateexpiry is not set' ); > > my $tomorrow = dt_from_string->add_duration( DateTime::Duration->new( days => 1 ) ); >- $item = $builder->build( { source => 'Item', value => { biblionumber => $builder->build( { source => 'Biblioitem' } )->{biblionumber} } } ); >+ $item = $builder->build_sample_item; > $patron = $builder->build_object( > { class => 'Koha::Patrons', > value => { >@@ -83,7 +83,7 @@ sub can_book_be_issued { > }, > } > ); >- ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $item->{barcode} ); >+ ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $item->barcode ); > is( not( exists $issuingimpossible->{EXPIRED} ), 1, 'The patron should not be considered as expired if dateexpiry is tomorrow' ); > > } >@@ -99,20 +99,20 @@ sub calc_date_due { > categorycode => $patron_category->{categorycode}, > } > }); >- my $item = $builder->build( { source => 'Item' } ); >+ my $item = $builder->build_sample_item; > my $branch = $builder->build( { source => 'Branch' } ); > my $today = dt_from_string(); > > # first test with empty expiry date > # note that this expiry date will never lead to an issue btw !! > $patron->{dateexpiry} = '0000-00-00'; >- my $d = C4::Circulation::CalcDateDue( $today, $item->{itype}, $branch->{branchcode}, $patron ); >+ my $d = C4::Circulation::CalcDateDue( $today, $item->effective_itemtype, $branch->{branchcode}, $patron ); > is( ref $d eq "DateTime" && $d->mdy() =~ /^\d+/, 1, "CalcDateDue with expiry 0000-00-00" ); > > # second test expiry date==today > my $d2 = output_pref( { dt => $today, dateonly => 1, dateformat => 'sql' } ); > $patron->{dateexpiry} = $d2; >- $d = C4::Circulation::CalcDateDue( $today, $item->{itype}, $branch->{branchcode}, $patron ); >+ $d = C4::Circulation::CalcDateDue( $today, $item->effective_itemtype, $branch->{branchcode}, $patron ); > is( ref $d eq "DateTime" && DateTime->compare( $d->truncate( to => 'day' ), $today->truncate( to => 'day' ) ) == 0, 1, "CalcDateDue with expiry today" ); > > # third test expiry date tomorrow >@@ -120,13 +120,13 @@ sub calc_date_due { > my $tomorrow = $today->clone->add_duration($dur); > $d2 = output_pref( { dt => $tomorrow, dateonly => 1, dateformat => 'sql' } ); > $patron->{dateexpiry} = $d2; >- $d = C4::Circulation::CalcDateDue( $today, $item->{itype}, $branch->{branchcode}, $patron ); >+ $d = C4::Circulation::CalcDateDue( $today, $item->effective_itemtype, $branch->{branchcode}, $patron ); > is( ref $d eq "DateTime" && $d->mdy() =~ /^\d+/, 1, "CalcDateDue with expiry tomorrow" ); > > # fourth test far future > $patron->{dateexpiry} = '9876-12-31'; > my $t1 = time; >- $d = C4::Circulation::CalcDateDue( $today, $item->{itype}, $branch->{branchcode}, $patron ); >+ $d = C4::Circulation::CalcDateDue( $today, $item->effective_itemtype, $branch->{branchcode}, $patron ); > my $t2 = time; > is( ref $d eq "DateTime" && $t2 - $t1 < 1, 1, "CalcDateDue with expiry in year 9876 in " . sprintf( "%6.4f", $t2 - $t1 ) . " seconds." ); > } >diff --git a/t/db_dependent/CourseReserves/CourseItems.t b/t/db_dependent/CourseReserves/CourseItems.t >index df179a922c..b34da74a7d 100644 >--- a/t/db_dependent/CourseReserves/CourseItems.t >+++ b/t/db_dependent/CourseReserves/CourseItems.t >@@ -492,22 +492,13 @@ sub create_dependent_objects { > } > > sub create_bib_and_item { >- my $biblio = $builder->build({ >- source => 'Biblio', >- value => { >- title => 'Title', >- } >- }); >- my $item = $builder->build({ >- source => 'Item', >- value => { >- biblionumber => $biblio->{biblionumber}, >- itype => 'CD_foo', >- ccode => 'CD', >- location => 'HR', >- homebranch => 'B1', >- holdingbranch => 'B1', >+ my $item = $builder->build_sample_item( >+ { >+ itype => 'CD_foo', >+ ccode => 'CD', >+ location => 'HR', >+ library => 'B1', > } >- }); >- return ($biblio->{biblionumber}, $item->{itemnumber}); >+ ); >+ return ($item->biblionumber, $item->itemnumber); > } >diff --git a/t/db_dependent/Exporter/Record.t b/t/db_dependent/Exporter/Record.t >index 5768a7e814..9993d7874b 100644 >--- a/t/db_dependent/Exporter/Record.t >+++ b/t/db_dependent/Exporter/Record.t >@@ -63,32 +63,25 @@ Koha::Biblio::Metadata->new( { biblionumber => $bad_biblio->id, format => 'marcx > my $bad_biblionumber = $bad_biblio->id; > > my $builder = t::lib::TestBuilder->new; >-my $item_1_1 = $builder->build({ >- source => 'Item', >- value => { >+my $item_1_1 = $builder->build_sample_item( >+ { > biblionumber => $biblionumber_1, >- more_subfields_xml => '', > } >-}); >-my $item_1_2 = $builder->build({ >- source => 'Item', >- value => { >+)->unblessed; >+my $item_1_2 = $builder->build_sample_item( >+ { > biblionumber => $biblionumber_1, >- more_subfields_xml => '', > } >-}); >-my $item_2_1 = $builder->build({ >- source => 'Item', >- value => { >+)->unblessed; >+my $item_2_1 = $builder->build_sample_item( >+ { > biblionumber => $biblionumber_2, >- more_subfields_xml => '', > } >-}); >-my $bad_item = $builder->build({ >+)->unblessed; >+my $bad_item = $builder->build({ # Cannot call build_sample_item, we want inconsistent data on purpose > source => 'Item', > value => { > biblionumber => $bad_biblionumber, >- more_subfields_xml => '', > } > }); > >@@ -223,24 +216,16 @@ subtest '_get_biblio_for_export' => sub { > my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $biblio, '' ); > my $branch_a = $builder->build({source => 'Branch',}); > my $branch_b = $builder->build({source => 'Branch',}); >- my $item_branch_a = $builder->build( >+ my $item_branch_a = $builder->build_sample_item( > { >- source => 'Item', >- value => { >- biblionumber => $biblionumber, >- homebranch => $branch_a->{branchcode}, >- more_subfields_xml => '', >- } >+ biblionumber => $biblionumber, >+ library => $branch_a->{branchcode}, > } > ); >- my $item_branch_b = $builder->build( >+ my $item_branch_b = $builder->build_sample_item( > { >- source => 'Item', >- value => { >- biblionumber => $biblionumber, >- homebranch => $branch_b->{branchcode}, >- more_subfields_xml => '', >- } >+ biblionumber => $biblionumber, >+ library => $branch_b->{branchcode}, > } > ); > >diff --git a/t/db_dependent/Holds/HoldFulfillmentPolicy.t b/t/db_dependent/Holds/HoldFulfillmentPolicy.t >index a835be3adf..de6b5bf594 100755 >--- a/t/db_dependent/Holds/HoldFulfillmentPolicy.t >+++ b/t/db_dependent/Holds/HoldFulfillmentPolicy.t >@@ -30,7 +30,7 @@ my $library2 = $builder->build({ > my $library3 = $builder->build({ > source => 'Branch', > }); >-my $itemtype = $builder->build({ source => 'Item' })->{itype}; >+my $itemtype = $builder->build_sample_item->itype; > > my $bib_title = "Test Title"; > >diff --git a/t/db_dependent/Holds/WaitingReserves.t b/t/db_dependent/Holds/WaitingReserves.t >index 292061def3..50b6ed8573 100644 >--- a/t/db_dependent/Holds/WaitingReserves.t >+++ b/t/db_dependent/Holds/WaitingReserves.t >@@ -59,57 +59,15 @@ my $patron2 = $builder->build({ > }, > }); > >-my $biblio = $builder->build({ >- source => 'Biblio', >- value => { >- title => 'Title 1', }, >-}); >- >-my $biblio2 = $builder->build({ >- source => 'Biblio', >- value => { >- title => 'Title 2', }, >-}); >- >-my $biblio3 = $builder->build({ >- source => 'Biblio', >- value => { >- title => 'Title 3', }, >-}); >- >-my $biblio4 = $builder->build({ >- source => 'Biblio', >- value => { >- title => 'Title 4', }, >-}); >- >-my $item1 = $builder->build({ >- source => 'Item', >- value => { >- biblionumber => $biblio->{biblionumber}, >- }, >-}); >+my $biblio = $builder->build_sample_biblio; >+my $biblio2 = $builder->build_sample_biblio; >+my $biblio3 = $builder->build_sample_biblio; >+my $biblio4 = $builder->build_sample_biblio; > >-my $item2 = $builder->build({ >- source => 'Item', >- value => { >- biblionumber => $biblio2->{biblionumber}, >- }, >-}); >- >-my $item3 = $builder->build({ >- source => 'Item', >- value => { >- biblionumber => $biblio3->{biblionumber}, >- }, >-}); >- >-my $item4 = $builder->build({ >- source => 'Item', >- value => { >- biblionumber => $biblio4->{biblionumber}, >- }, >-}); >+my $item1 = $builder->build_sample_item({biblionumber => $biblio->biblionumber}); >+my $item2 = $builder->build_sample_item({biblionumber => $biblio2->biblionumber}); >+my $item3 = $builder->build_sample_item({biblionumber => $biblio3->biblionumber}); >+my $item4 = $builder->build_sample_item({biblionumber => $biblio4->biblionumber}); > > my $today = dt_from_string(); > >@@ -125,7 +83,7 @@ my $reserve1 = $builder->build({ > borrowernumber => $patron1->{borrowernumber}, > reservedate => $reserve1_reservedate->ymd, > expirationdate => undef, >- biblionumber => $biblio->{biblionumber}, >+ biblionumber => $biblio->biblionumber, > branchcode => 'LIB1', > priority => 1, > found => '', >@@ -135,14 +93,14 @@ my $reserve1 = $builder->build({ > t::lib::Mocks::mock_preference('ExpireReservesMaxPickUpDelay', 1); > t::lib::Mocks::mock_preference('ReservesMaxPickUpDelay', 6); > >-ModReserveAffect( $item1->{itemnumber}, $patron1->{borrowernumber}); >+ModReserveAffect( $item1->itemnumber, $patron1->{borrowernumber}); > my $r = Koha::Holds->find($reserve1->{reserve_id}); > > is($r->waitingdate, $today->ymd, 'Waiting date should be set to today' ); > is($r->expirationdate, $reserve1_expirationdate->ymd, 'Expiration date should be set to today + 6' ); > is($r->found, 'W', 'Reserve status is now "waiting"' ); > is($r->priority, 0, 'Priority should be 0' ); >-is($r->itemnumber, $item1->{itemnumber}, 'Item number should be set correctly' ); >+is($r->itemnumber, $item1->itemnumber, 'Item number should be set correctly' ); > > my $reserve2 = $builder->build({ > source => 'Reserve', >@@ -150,19 +108,19 @@ my $reserve2 = $builder->build({ > borrowernumber => $patron2->{borrowernumber}, > reservedate => $reserve1_reservedate->ymd, > expirationdate => undef, >- biblionumber => $biblio2->{biblionumber}, >+ biblionumber => $biblio2->biblionumber, > branchcode => 'LIB1', > priority => 1, > found => '', > }, > }); > >-ModReserveAffect( $item2->{itemnumber}, $patron2->{borrowernumber}, 1); >+ModReserveAffect( $item2->itemnumber, $patron2->{borrowernumber}, 1); > my $r2 = Koha::Holds->find($reserve2->{reserve_id}); > > is($r2->found, 'T', '2nd reserve - Reserve status is now "To transfer"' ); > is($r2->priority, 0, '2nd reserve - Priority should be 0' ); >-is($r2->itemnumber, $item2->{itemnumber}, '2nd reserve - Item number should be set correctly' ); >+is($r2->itemnumber, $item2->itemnumber, '2nd reserve - Item number should be set correctly' ); > > my $reserve3 = $builder->build({ > source => 'Reserve', >@@ -170,7 +128,7 @@ my $reserve3 = $builder->build({ > borrowernumber => $patron2->{borrowernumber}, > reservedate => $reserve1_reservedate->ymd, > expirationdate => undef, >- biblionumber => $biblio3->{biblionumber}, >+ biblionumber => $biblio3->biblionumber, > branchcode => 'LIB1', > priority => 1, > found => '', >@@ -210,7 +168,7 @@ my $holiday2 = $builder->build({ > Koha::Caches->get_instance->flush_all; > > t::lib::Mocks::mock_preference('ExcludeHolidaysFromMaxPickUpDelay', 1); >-ModReserveAffect( $item3->{itemnumber}, $patron2->{borrowernumber}); >+ModReserveAffect( $item3->itemnumber, $patron2->{borrowernumber}); > > # Add 6 days of pickup delay + 1 day of holiday. > my $expected_expiration = $today->clone; >@@ -228,7 +186,7 @@ my $reserve4 = $builder->build({ > borrowernumber => $patron2->{borrowernumber}, > reservedate => $reserve4_reservedate->ymd, > expirationdate => $requested_expiredate->ymd, >- biblionumber => $biblio4->{biblionumber}, >+ biblionumber => $biblio4->biblionumber, > branchcode => 'LIB1', > priority => 1, > found => '', >@@ -236,7 +194,7 @@ my $reserve4 = $builder->build({ > }); > > t::lib::Mocks::mock_preference('ReservesMaxPickUpDelay', 10); >-ModReserveAffect( $item4->{itemnumber}, $patron2->{borrowernumber}, 0, $reserve4->{reserve_id}); >+ModReserveAffect( $item4->itemnumber, $patron2->{borrowernumber}, 0, $reserve4->{reserve_id}); > > my $r4 = Koha::Holds->find($reserve4->{reserve_id}); > is($r4->expirationdate, $requested_expiredate->ymd, 'Requested expiration date should be kept' ); >diff --git a/t/db_dependent/ILSDI_Services.t b/t/db_dependent/ILSDI_Services.t >index 3f253149e3..3b599b67f0 100644 >--- a/t/db_dependent/ILSDI_Services.t >+++ b/t/db_dependent/ILSDI_Services.t >@@ -310,77 +310,47 @@ subtest 'Holds test' => sub { > source => 'Borrower', > }); > >- my $biblio = $builder->build({ >- source => 'Biblio', >- }); >- >- my $biblioitems = $builder->build({ >- source => 'Biblioitem', >- value => { >- biblionumber => $biblio->{biblionumber}, >- } >- }); >- >- my $item = $builder->build({ >- source => 'Item', >- value => { >- biblionumber => $biblio->{biblionumber}, >+ my $item = $builder->build_sample_item( >+ { > damaged => 1 > } >- }); >+ ); > > my $query = new CGI; > $query->param( 'patron_id', $patron->{borrowernumber}); >- $query->param( 'bib_id', $biblio->{biblionumber}); >+ $query->param( 'bib_id', $item->biblionumber); > > my $reply = C4::ILSDI::Services::HoldTitle( $query ); > is( $reply->{code}, 'damaged', "Item damaged" ); > >- my $item_o = Koha::Items->find($item->{itemnumber}); >- $item_o->damaged(0)->store; >+ $item->damaged(0)->store; > > my $hold = $builder->build({ > source => 'Reserve', > value => { > borrowernumber => $patron->{borrowernumber}, >- biblionumber => $biblio->{biblionumber}, >- itemnumber => $item->{itemnumber} >+ biblionumber => $item->biblionumber, >+ itemnumber => $item->itemnumber > } > }); > > $reply = C4::ILSDI::Services::HoldTitle( $query ); > is( $reply->{code}, 'itemAlreadyOnHold', "Item already on hold" ); > >- my $biblio_with_no_item = $builder->build({ >- source => 'Biblio', >- }); >+ my $biblio_with_no_item = $builder->build_sample_biblio; > > $query = new CGI; > $query->param( 'patron_id', $patron->{borrowernumber}); >- $query->param( 'bib_id', $biblio_with_no_item->{biblionumber}); >+ $query->param( 'bib_id', $biblio_with_no_item->biblionumber); > > $reply = C4::ILSDI::Services::HoldTitle( $query ); > is( $reply->{code}, 'NoItems', 'Biblio has no item' ); > >- my $biblio2 = $builder->build({ >- source => 'Biblio', >- }); >- >- my $biblioitems2 = $builder->build({ >- source => 'Biblioitem', >- value => { >- biblionumber => $biblio2->{biblionumber}, >- } >- }); >- >- my $item2 = $builder->build({ >- source => 'Item', >- value => { >- biblionumber => $biblio2->{biblionumber}, >+ my $item2 = $builder->build_sample_item( >+ { > damaged => 0, >- itype => $builder->build_object({ class => 'Koha::ItemTypes' })->itemtype, > } >- }); >+ ); > > t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'PatronLibrary' ); > Koha::CirculationRules->set_rule( >@@ -395,41 +365,25 @@ subtest 'Holds test' => sub { > > $query = new CGI; > $query->param( 'patron_id', $patron->{borrowernumber}); >- $query->param( 'bib_id', $biblio2->{biblionumber}); >- $query->param( 'item_id', $item2->{itemnumber}); >+ $query->param( 'bib_id', $item2->biblionumber); >+ $query->param( 'item_id', $item2->itemnumber); > > $reply = C4::ILSDI::Services::HoldItem( $query ); > is( $reply->{code}, 'tooManyReserves', "Too many reserves" ); > >- my $biblio3 = $builder->build({ >- source => 'Biblio', >- }); >- >- my $biblioitems3 = $builder->build({ >- source => 'Biblioitem', >- value => { >- biblionumber => $biblio3->{biblionumber}, >- } >- }); >- > # Adding a holdable item to biblio 3. >- my $item3 = $builder->build({ >- source => 'Item', >- value => { >- biblionumber => $biblio3->{biblionumber}, >+ my $item3 = $builder->build_sample_item( >+ { > damaged => 0, >- itype => $builder->build_object({ class => 'Koha::ItemTypes' })->itemtype, > } >- }); >+ ); > >- my $item4 = $builder->build({ >- source => 'Item', >- value => { >- biblionumber => $biblio3->{biblionumber}, >- damaged => 1, >- itype => $builder->build_object({ class => 'Koha::ItemTypes' })->itemtype, >+ my $item4 = $builder->build_sample_item( >+ { >+ biblionumber => $item3->biblionumber, >+ damaged => 1, > } >- }); >+ ); > > Koha::CirculationRules->set_rule( > { >@@ -443,8 +397,8 @@ subtest 'Holds test' => sub { > > $query = new CGI; > $query->param( 'patron_id', $patron->{borrowernumber}); >- $query->param( 'bib_id', $biblio3->{biblionumber}); >- $query->param( 'item_id', $item4->{itemnumber}); >+ $query->param( 'bib_id', $item3->biblionumber); >+ $query->param( 'item_id', $item4->itemnumber); > > $reply = C4::ILSDI::Services::HoldItem( $query ); > is( $reply->{code}, 'damaged', "Item is damaged" ); >@@ -483,26 +437,11 @@ subtest 'Holds test for branch transfer limits' => sub { > } > ); > >- my $biblio = $builder->build({ >- source => 'Biblio', >- }); >- my $biblioitem = $builder->build({ >- source => 'Biblioitem', >- value => { >- biblionumber => $biblio->{biblionumber}, >- } >- }); >- my $item = $builder->build({ >- source => 'Item', >- value => { >- homebranch => $origin_branch->{branchcode}, >- holdingbranch => $origin_branch->{branchcode}, >- biblionumber => $biblio->{biblionumber}, >- damaged => 0, >- itemlost => 0, >- itype => $builder->build_object({ class => 'Koha::ItemTypes' })->itemtype, >+ my $item = $builder->build_sample_item( >+ { >+ library => $origin_branch->{branchcode}, > } >- }); >+ ); > > Koha::CirculationRules->set_rule( > { >@@ -516,15 +455,15 @@ subtest 'Holds test for branch transfer limits' => sub { > > my $limit = Koha::Item::Transfer::Limit->new({ > toBranch => $pickup_branch->{branchcode}, >- fromBranch => $item->{holdingbranch}, >- itemtype => $item->{itype}, >+ fromBranch => $item->holdingbranch, >+ itemtype => $item->effective_itemtype, > })->store(); > > my $query = new CGI; > $query->param( 'pickup_location', $pickup_branch->{branchcode} ); > $query->param( 'patron_id', $patron->{borrowernumber}); >- $query->param( 'bib_id', $biblio->{biblionumber}); >- $query->param( 'item_id', $item->{itemnumber}); >+ $query->param( 'bib_id', $item->biblionumber); >+ $query->param( 'item_id', $item->itemnumber); > > my $reply = C4::ILSDI::Services::HoldItem( $query ); > is( $reply->{code}, 'cannotBeTransferred', "Item hold, Item cannot be transferred" ); >@@ -536,14 +475,14 @@ subtest 'Holds test for branch transfer limits' => sub { > > $reply = C4::ILSDI::Services::HoldItem( $query ); > is( $reply->{code}, undef, "Item hold, Item can be transferred" ); >- my $hold = Koha::Holds->search({ itemnumber => $item->{itemnumber}, borrowernumber => $patron->{borrowernumber} })->next; >+ my $hold = Koha::Holds->search({ itemnumber => $item->itemnumber, borrowernumber => $patron->{borrowernumber} })->next; > is( $hold->branchcode, $pickup_branch->{branchcode}, 'The library id is correctly set' ); > > Koha::Holds->search()->delete(); > > $reply = C4::ILSDI::Services::HoldTitle( $query ); > is( $reply->{code}, undef, "Record hold, Item con be transferred" ); >- $hold = Koha::Holds->search({ biblionumber => $biblio->{biblionumber}, borrowernumber => $patron->{borrowernumber} })->next; >+ $hold = Koha::Holds->search({ biblionumber => $item->biblionumber, borrowernumber => $patron->{borrowernumber} })->next; > is( $hold->branchcode, $pickup_branch->{branchcode}, 'The library id is correctly set' ); > > $schema->storage->txn_rollback; >@@ -622,30 +561,17 @@ subtest 'GetRecords' => sub { > source => 'Branch', > }); > >- my $biblio = $builder->build({ >- source => 'Biblio', >- }); >- my $biblioitem = $builder->build({ >- source => 'Biblioitem', >- value => { >- biblionumber => $biblio->{biblionumber}, >- }, >- }); >- my $item = $builder->build_object({ >- class => 'Koha::Items', >- value => { >- biblionumber => $biblio->{biblionumber}, >- biblioitemnumber => $biblioitem->{biblioitemnumber}, >- homebranch => $branch1->{branchcode}, >- holdingbranch => $branch1->{branchcode}, >- }, >- }); >+ my $item = $builder->build_sample_item( >+ { >+ library => $branch1->{branchcode}, >+ } >+ ); > > ModItemTransfer($item->itemnumber, $branch1->{branchcode}, $branch2->{branchcode}); > > my $cgi = new CGI; > $cgi->param(service => 'GetRecords'); >- $cgi->param(id => $biblio->{biblionumber}); >+ $cgi->param(id => $item->biblionumber); > > my $reply = C4::ILSDI::Services::GetRecords($cgi); > >@@ -668,7 +594,7 @@ subtest 'RenewHold' => sub { > > my $cgi = new CGI; > my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >- my $item = $builder->build_object( { class => 'Koha::Items' } ); >+ my $item = $builder->build_sample_item; > $cgi->param( patron_id => $patron->borrowernumber ); > $cgi->param( item_id => $item->itemnumber ); > >diff --git a/t/db_dependent/ImportBatch.t b/t/db_dependent/ImportBatch.t >index f437edc39b..e4c3676692 100644 >--- a/t/db_dependent/ImportBatch.t >+++ b/t/db_dependent/ImportBatch.t >@@ -133,7 +133,7 @@ is_deeply( $record_from_import_biblio_without_items, $original_record, 'GetRecor > # Add a few tests for GetItemNumbersFromImportBatch > my @a = GetItemNumbersFromImportBatch( $id_import_batch1 ); > is( @a, 0, 'No item numbers expected since we did not commit' ); >-my $itemno = $builder->build({ source => 'Item' })->{itemnumber}; >+my $itemno = $builder->build_sample_item->itemnumber; > # Link this item to the import item to fool GetItemNumbersFromImportBatch > my $sql = "UPDATE import_items SET itemnumber=? WHERE import_record_id=?"; > $dbh->do( $sql, undef, $itemno, $import_record_id ); >diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t >index 010b41e97a..b3a0247c32 100755 >--- a/t/db_dependent/Items.t >+++ b/t/db_dependent/Items.t >@@ -895,14 +895,14 @@ subtest 'Check stockrotationitem relationship' => sub { > $schema->storage->txn_begin(); > > my $builder = t::lib::TestBuilder->new; >- my $item = $builder->build({ source => 'Item' }); >+ my $item = $builder->build_sample_item; > > $builder->build({ > source => 'Stockrotationitem', >- value => { itemnumber_id => $item->{itemnumber} } >+ value => { itemnumber_id => $item->itemnumber } > }); > >- my $sritem = Koha::Items->find($item->{itemnumber})->stockrotationitem; >+ my $sritem = Koha::Items->find($item->itemnumber)->stockrotationitem; > isa_ok( $sritem, 'Koha::StockRotationItem', "Relationship works and correctly creates Koha::Object." ); > > $schema->storage->txn_rollback; >@@ -914,7 +914,7 @@ subtest 'Check add_to_rota method' => sub { > $schema->storage->txn_begin(); > > my $builder = t::lib::TestBuilder->new; >- my $item = $builder->build({ source => 'Item' }); >+ my $item = $builder->build_sample_item; > my $rota = $builder->build({ source => 'Stockrotationrota' }); > my $srrota = Koha::StockRotationRotas->find($rota->{rota_id}); > >@@ -923,11 +923,11 @@ subtest 'Check add_to_rota method' => sub { > value => { rota_id => $rota->{rota_id} }, > }); > >- my $sritem = Koha::Items->find($item->{itemnumber}); >+ my $sritem = Koha::Items->find($item->itemnumber); > $sritem->add_to_rota($rota->{rota_id}); > > is( >- Koha::StockRotationItems->find($item->{itemnumber})->stage_id, >+ Koha::StockRotationItems->find($item->itemnumber)->stage_id, > $srrota->stockrotationstages->next->stage_id, > "Adding to a rota a new sritem item being assigned to its first stage." > ); >@@ -944,7 +944,7 @@ subtest 'Check add_to_rota method' => sub { > $sritem->add_to_rota($newrota->{rota_id}); > > is( >- Koha::StockRotationItems->find($item->{itemnumber})->stage_id, >+ Koha::StockRotationItems->find($item->itemnumber)->stage_id, > $srnewrota->stockrotationstages->next->stage_id, > "Moving an item results in that sritem being assigned to the new first stage." > ); >@@ -957,8 +957,7 @@ subtest 'Split subfields in Item2Marc (Bug 21774)' => sub { > $schema->storage->txn_begin; > > my $builder = t::lib::TestBuilder->new; >- my $biblio = $builder->build({ source => 'Biblio', value => { frameworkcode => q{} } }); >- my $item = $builder->build({ source => 'Item', value => { biblionumber => $biblio->{biblionumber}, ccode => 'A|B' } }); >+ my $item = $builder->build_sample_item({ ccode => 'A|B' }); > > Koha::MarcSubfieldStructures->search({ tagfield => '952', tagsubfield => '8' })->delete; # theoretical precaution > Koha::MarcSubfieldStructures->search({ kohafield => 'items.ccode' })->delete; >@@ -974,7 +973,7 @@ subtest 'Split subfields in Item2Marc (Bug 21774)' => sub { > Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); > > # Start testing >- my $marc = C4::Items::Item2Marc( $item, $biblio->{biblionumber} ); >+ my $marc = C4::Items::Item2Marc( $item->unblessed, $item->biblionumber ); > my @subs = $marc->subfield( $mapping->tagfield, $mapping->tagsubfield ); > is( @subs, 2, 'Expect two subfields' ); > is( $subs[0], 'A', 'First subfield matches' ); >diff --git a/t/db_dependent/Items/GetHostItemsInfo.t b/t/db_dependent/Items/GetHostItemsInfo.t >index 5f4a5c3023..63e8ea423c 100644 >--- a/t/db_dependent/Items/GetHostItemsInfo.t >+++ b/t/db_dependent/Items/GetHostItemsInfo.t >@@ -14,14 +14,14 @@ subtest 'GetHostItemsInfo' => sub { > plan tests => 3; > > my $builder = t::lib::TestBuilder->new; >- my $bib1 = $builder->build({ source => 'Biblio' }); >- my $itm1 = $builder->build({ source => 'Item', value => { biblionumber => $bib1->{biblionumber} }}); >- my $itm2 = $builder->build({ source => 'Item', value => { biblionumber => $bib1->{biblionumber} }}); >+ my $bib1 = $builder->build_sample_biblio; >+ my $itm1 = $builder->build_sample_item({ biblionumber => $bib1->biblionumber }); >+ my $itm2 = $builder->build_sample_item({ biblionumber => $bib1->biblionumber }); > my $marc = MARC::Record->new; > $marc->append_fields( >- MARC::Field->new( '461', '', '', 0 => $bib1->{biblionumber}, 9 => $itm1->{itemnumber} ), >- MARC::Field->new( '773', '', '', 0 => $bib1->{biblionumber}, 9 => $itm1->{itemnumber} ), >- MARC::Field->new( '773', '', '', 0 => $bib1->{biblionumber}, 9 => $itm2->{itemnumber} ), >+ MARC::Field->new( '461', '', '', 0 => $bib1->biblionumber, 9 => $itm1->itemnumber ), >+ MARC::Field->new( '773', '', '', 0 => $bib1->biblionumber, 9 => $itm1->itemnumber ), >+ MARC::Field->new( '773', '', '', 0 => $bib1->biblionumber, 9 => $itm2->itemnumber ), > ); > > t::lib::Mocks::mock_preference('marcflavour', 'MARC21'); >diff --git a/t/db_dependent/Items/GetItemsForInventory.t b/t/db_dependent/Items/GetItemsForInventory.t >index 20993514ab..f7c221c87e 100755 >--- a/t/db_dependent/Items/GetItemsForInventory.t >+++ b/t/db_dependent/Items/GetItemsForInventory.t >@@ -164,7 +164,7 @@ subtest 'Use cn_sort rather than callnumber to determine correct location' => su > class_source => $class_source->{cn_source}, > }); > >- my $item_1 = $builder->build({ >+ my $item_1 = $builder->build({ # Cannot call build_sample_item or cn_sort will be replaced by Koha::Item->store > source => 'Item', > value => { > itemcallnumber => 'GT95', >diff --git a/t/db_dependent/Items/MoveItemFromBiblio.t b/t/db_dependent/Items/MoveItemFromBiblio.t >index fec7e51442..75ae92afe0 100644 >--- a/t/db_dependent/Items/MoveItemFromBiblio.t >+++ b/t/db_dependent/Items/MoveItemFromBiblio.t >@@ -31,69 +31,55 @@ my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; > my $builder = t::lib::TestBuilder->new; > >-# NOTE This is a trick, if we want to populate the biblioitems table, we should not create a Biblio but a Biblioitem >-my $param = { source => 'Biblioitem' }; >-my $from_biblio = { >- biblionumber => $builder->build($param)->{biblionumber}, >-}; >-my $to_biblio = { >- biblionumber => $builder->build($param)->{biblionumber}, >-}; >- >-my $item1 = $builder->build( >- { source => 'Item', >- value => { biblionumber => $from_biblio->{biblionumber}, }, >- } >-); >-my $item2 = $builder->build( >- { source => 'Item', >- value => { biblionumber => $from_biblio->{biblionumber}, }, >- } >-); >-my $item3 = $builder->build( >- { source => 'Item', >- value => { biblionumber => $to_biblio->{biblionumber}, }, >- } >-); >+my $from_biblio = $builder->build_sample_biblio; >+my $to_biblio = $builder->build_sample_biblio; >+ >+my $item1 = $builder->build_sample_item( >+ { biblionumber => $from_biblio->biblionumber, } ); >+my $item2 = $builder->build_sample_item( >+ { biblionumber => $from_biblio->biblionumber, } ); >+my $item3 = $builder->build_sample_item( >+ { biblionumber => $to_biblio->biblionumber, } ); >+ > > my $bib_level_hold_not_to_move = $builder->build( > { source => 'Reserve', >- value => { biblionumber => $from_biblio->{biblionumber}, }, >+ value => { biblionumber => $from_biblio->biblionumber, }, > } > ); > my $item_level_hold_not_to_move = $builder->build( > { source => 'Reserve', >- value => { biblionumber => $from_biblio->{biblionumber}, itemnumber => $item1->{itemnumber} }, >+ value => { biblionumber => $from_biblio->biblionumber, itemnumber => $item1->itemnumber }, > } > ); > my $item_level_hold_to_move = $builder->build( > { source => 'Reserve', >- value => { biblionumber => $from_biblio->{biblionumber}, itemnumber => $item2->{itemnumber} }, >+ value => { biblionumber => $from_biblio->biblionumber, itemnumber => $item2->itemnumber }, > } > ); > >-my $to_biblionumber_after_moved = C4::Items::MoveItemFromBiblio( $item2->{itemnumber}, $from_biblio->{biblionumber}, $to_biblio->{biblionumber} ); >+my $to_biblionumber_after_moved = C4::Items::MoveItemFromBiblio( $item2->itemnumber, $from_biblio->biblionumber, $to_biblio->biblionumber ); > >-is( $to_biblionumber_after_moved, $to_biblio->{biblionumber}, 'MoveItemFromBiblio should return the to_biblionumber if success' ); >+is( $to_biblionumber_after_moved, $to_biblio->biblionumber, 'MoveItemFromBiblio should return the to_biblionumber if success' ); > >-$to_biblionumber_after_moved = C4::Items::MoveItemFromBiblio( $item2->{itemnumber}, $from_biblio->{biblionumber}, $to_biblio->{biblionumber} ); >+$to_biblionumber_after_moved = C4::Items::MoveItemFromBiblio( $item2->itemnumber, $from_biblio->biblionumber, $to_biblio->biblionumber ); > > is( $to_biblionumber_after_moved, undef, 'MoveItemFromBiblio should return undef if the move has failed. If called twice, the item is not attached to the first biblio anymore' ); > >-my $get_item1 = Koha::Items->find( $item1->{itemnumber} ); >-is( $get_item1->biblionumber, $from_biblio->{biblionumber}, 'The item1 should not have been moved' ); >-my $get_item2 = Koha::Items->find( $item2->{itemnumber} ); >-is( $get_item2->biblionumber, $to_biblio->{biblionumber}, 'The item2 should have been moved' ); >-my $get_item3 = Koha::Items->find( $item3->{itemnumber} ); >-is( $get_item3->biblionumber, $to_biblio->{biblionumber}, 'The item3 should not have been moved' ); >+my $get_item1 = Koha::Items->find( $item1->itemnumber ); >+is( $get_item1->biblionumber, $from_biblio->biblionumber, 'The item1 should not have been moved' ); >+my $get_item2 = Koha::Items->find( $item2->itemnumber ); >+is( $get_item2->biblionumber, $to_biblio->biblionumber, 'The item2 should have been moved' ); >+my $get_item3 = Koha::Items->find( $item3->itemnumber ); >+is( $get_item3->biblionumber, $to_biblio->biblionumber, 'The item3 should not have been moved' ); > > my $get_bib_level_hold = Koha::Holds->find( $bib_level_hold_not_to_move->{reserve_id} ); > my $get_item_level_hold_1 = Koha::Holds->find( $item_level_hold_not_to_move->{reserve_id} ); > my $get_item_level_hold_2 = Koha::Holds->find( $item_level_hold_to_move->{reserve_id} ); > >-is( $get_bib_level_hold->biblionumber, $from_biblio->{biblionumber}, 'MoveItemFromBiblio should not have moved the biblio-level hold' ); >-is( $get_item_level_hold_1->biblionumber, $from_biblio->{biblionumber}, 'MoveItemFromBiblio should not have moved the item-level hold placed on item 1' ); >-is( $get_item_level_hold_2->biblionumber, $to_biblio->{biblionumber}, 'MoveItemFromBiblio should have moved the item-level hold placed on item 2' ); >+is( $get_bib_level_hold->biblionumber, $from_biblio->biblionumber, 'MoveItemFromBiblio should not have moved the biblio-level hold' ); >+is( $get_item_level_hold_1->biblionumber, $from_biblio->biblionumber, 'MoveItemFromBiblio should not have moved the item-level hold placed on item 1' ); >+is( $get_item_level_hold_2->biblionumber, $to_biblio->biblionumber, 'MoveItemFromBiblio should have moved the item-level hold placed on item 2' ); > > $schema->storage->txn_rollback; > >diff --git a/t/db_dependent/Koha/Account/Line.t b/t/db_dependent/Koha/Account/Line.t >index fc4901ca54..fe0376388c 100644 >--- a/t/db_dependent/Koha/Account/Line.t >+++ b/t/db_dependent/Koha/Account/Line.t >@@ -73,17 +73,14 @@ subtest 'item() tests' => sub { > $schema->storage->txn_begin; > > my $library = $builder->build( { source => 'Branch' } ); >- my $biblioitem = $builder->build( { source => 'Biblioitem' } ); > my $patron = $builder->build( { source => 'Borrower' } ); >- my $item = Koha::Item->new( >- { >- biblionumber => $biblioitem->{biblionumber}, >- biblioitemnumber => $biblioitem->{biblioitemnumber}, >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- barcode => 'some_barcode_12', >- itype => 'BK', >- })->store; >+ my $item = $builder->build_sample_item( >+ { >+ library => $library->{branchcode}, >+ barcode => 'some_barcode_12', >+ itype => 'BK', >+ } >+ ); > > my $line = Koha::Account::Line->new( > { >@@ -347,7 +344,7 @@ subtest 'Keep account info when related patron, staff, item or cash_register is > > my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); > my $staff = $builder->build_object( { class => 'Koha::Patrons' } ); >- my $item = $builder->build_object({ class => 'Koha::Items' }); >+ my $item = $builder->build_sample_item; > my $issue = $builder->build_object( > { > class => 'Koha::Checkouts', >diff --git a/t/db_dependent/Koha/Biblios.t b/t/db_dependent/Koha/Biblios.t >index a6af46d288..fcba56dcd7 100644 >--- a/t/db_dependent/Koha/Biblios.t >+++ b/t/db_dependent/Koha/Biblios.t >@@ -96,23 +96,17 @@ subtest 'holds + current_holds' => sub { > > subtest 'waiting_or_in_transit' => sub { > plan tests => 4; >- my $biblio = $builder->build( { source => 'Biblio' } ); >- my $item = $builder->build({ >- source => 'Item', >- value => { >- biblionumber => $biblio->{biblionumber} >- } >- }); >+ my $item = $builder->build_sample_item; > my $reserve = $builder->build({ > source => 'Reserve', > value => { >- biblionumber => $biblio->{biblionumber}, >+ biblionumber => $item->biblionumber, > found => undef > } > }); > > $reserve = Koha::Holds->find($reserve->{reserve_id}); >- $biblio = Koha::Biblios->find($biblio->{biblionumber}); >+ $biblio = $item->biblio; > > is($biblio->has_items_waiting_or_intransit, 0, 'Item is neither waiting nor in transit'); > >@@ -125,7 +119,7 @@ subtest 'waiting_or_in_transit' => sub { > my $transfer = $builder->build({ > source => 'Branchtransfer', > value => { >- itemnumber => $item->{itemnumber}, >+ itemnumber => $item->itemnumber, > datearrived => undef > } > }); >diff --git a/t/db_dependent/Koha/Checkouts.t b/t/db_dependent/Koha/Checkouts.t >index dfb90e42a8..d037970a40 100644 >--- a/t/db_dependent/Koha/Checkouts.t >+++ b/t/db_dependent/Koha/Checkouts.t >@@ -34,18 +34,18 @@ $schema->storage->txn_begin; > my $builder = t::lib::TestBuilder->new; > my $library = $builder->build( { source => 'Branch' } ); > my $patron = $builder->build( { source => 'Borrower', value => { branchcode => $library->{branchcode} } } ); >-my $item_1 = $builder->build( { source => 'Item' } ); >-my $item_2 = $builder->build( { source => 'Item' } ); >+my $item_1 = $builder->build_sample_item; >+my $item_2 = $builder->build_sample_item; > my $nb_of_checkouts = Koha::Checkouts->search->count; > my $new_checkout_1 = Koha::Checkout->new( > { borrowernumber => $patron->{borrowernumber}, >- itemnumber => $item_1->{itemnumber}, >+ itemnumber => $item_1->itemnumber, > branchcode => $library->{branchcode}, > } > )->store; > my $new_checkout_2 = Koha::Checkout->new( > { borrowernumber => $patron->{borrowernumber}, >- itemnumber => $item_2->{itemnumber}, >+ itemnumber => $item_2->itemnumber, > branchcode => $library->{branchcode}, > } > )->store; >@@ -91,14 +91,14 @@ subtest 'item' => sub { > plan tests => 2; > my $item = $retrieved_checkout_1->item; > is( ref( $item ), 'Koha::Item', 'Koha::Checkout->item should return a Koha::Item' ); >- is( $item->itemnumber, $item_1->{itemnumber}, 'Koha::Checkout->item should return the correct item' ); >+ is( $item->itemnumber, $item_1->itemnumber, 'Koha::Checkout->item should return the correct item' ); > }; > > subtest 'patron' => sub { > plan tests => 3; > my $patron = $builder->build_object({class=>'Koha::Patrons', value => {branchcode => $library->{branchcode}}}); > >- my $item = $builder->build_object( { class=> 'Koha::Items' } ); >+ my $item = $builder->build_sample_item; > my $checkout = Koha::Checkout->new( > { borrowernumber => $patron->borrowernumber, > itemnumber => $item->itemnumber, >diff --git a/t/db_dependent/Koha/Filter/EmbedItemsAvailability.t b/t/db_dependent/Koha/Filter/EmbedItemsAvailability.t >index 2cf381bd60..d4a7b2d677 100755 >--- a/t/db_dependent/Koha/Filter/EmbedItemsAvailability.t >+++ b/t/db_dependent/Koha/Filter/EmbedItemsAvailability.t >@@ -62,31 +62,22 @@ subtest 'EmbedItemsAvailability tests' => sub { > my ( $biblionumber, $biblioitemnumber ) = AddBiblio(MARC::Record->new(), ''); > > # Add some items with different onloan values >- $builder->build( >- { source => 'Item', >- value => { >- biblionumber => $biblionumber, >- biblioitemnumber => $biblioitemnumber, >- onloan => '2017-01-01' >- } >+ $builder->build_sample_item( >+ { >+ biblionumber => $biblionumber, >+ onloan => '2017-01-01' > } > ); >- $builder->build( >- { source => 'Item', >- value => { >- biblionumber => $biblionumber, >- biblioitemnumber => $biblioitemnumber, >- onloan => undef >- } >+ $builder->build_sample_item( >+ { >+ biblionumber => $biblionumber, >+ onloan => undef > } > ); >- $builder->build( >- { source => 'Item', >- value => { >- biblionumber => $biblionumber, >- biblioitemnumber => $biblioitemnumber, >- onloan => '2017-01-02' >- } >+ $builder->build_sample_item( >+ { >+ biblionumber => $biblionumber, >+ onloan => '2017-01-02' > } > ); > >@@ -110,31 +101,22 @@ subtest 'EmbedItemsAvailability tests' => sub { > ( $biblionumber, $biblioitemnumber ) = AddBiblio(MARC::Record->new(), ''); > > # Add some items with different onloan values >- $builder->build( >- { source => 'Item', >- value => { >- biblionumber => $biblionumber, >- biblioitemnumber => $biblioitemnumber, >- onloan => '2017-01-01' >- } >+ $builder->build_sample_item( >+ { >+ biblionumber => $biblionumber, >+ onloan => '2017-01-01' > } > ); >- $builder->build( >- { source => 'Item', >- value => { >- biblionumber => $biblionumber, >- biblioitemnumber => $biblioitemnumber, >- onloan => undef >- } >+ $builder->build_sample_item( >+ { >+ biblionumber => $biblionumber, >+ onloan => undef > } > ); >- $builder->build( >- { source => 'Item', >- value => { >- biblionumber => $biblionumber, >- biblioitemnumber => $biblioitemnumber, >- onloan => '2017-01-02' >- } >+ $builder->build_sample_item( >+ { >+ biblionumber => $biblionumber, >+ onloan => '2017-01-02' > } > ); > >diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t >index 44cd0b8e2b..0309fa94f6 100644 >--- a/t/db_dependent/Koha/Item.t >+++ b/t/db_dependent/Koha/Item.t >@@ -192,25 +192,23 @@ subtest 'pickup_locations' => sub { > my $group2_1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library3->branchcode } } ); > my $group2_2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library4->branchcode } } ); > >- my $biblioitem = $builder->build( { source => 'Biblioitem' } ); >- >- my $item1 = Koha::Item->new({ >- biblionumber => $biblioitem->{biblionumber}, >- biblioitemnumber => $biblioitem->{biblioitemnumber}, >- homebranch => $library1->branchcode, >- holdingbranch => $library2->branchcode, >- barcode => '1', >- itype => 'test', >- })->store; >- >- my $item3 = Koha::Item->new({ >- biblionumber => $biblioitem->{biblionumber}, >- biblioitemnumber => $biblioitem->{biblioitemnumber}, >- homebranch => $library3->branchcode, >- holdingbranch => $library4->branchcode, >- barcode => '3', >- itype => 'test', >- })->store; >+ my $item1 = $builder->build_sample_item( >+ { >+ homebranch => $library1->branchcode, >+ holdingbranch => $library2->branchcode, >+ barcode => '1', >+ itype => 'test', >+ } >+ )->store; >+ >+ my $item3 = $builder->build_sample_item( >+ { >+ homebranch => $library3->branchcode, >+ holdingbranch => $library4->branchcode, >+ barcode => '3', >+ itype => 'test', >+ } >+ )->store; > > my $patron1 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library1->branchcode, firstname => '1' } } ); > my $patron4 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library4->branchcode, firstname => '4' } } ); >diff --git a/t/db_dependent/Koha/Item/Transfers.t b/t/db_dependent/Koha/Item/Transfers.t >index 28e070671f..03ed3cf3aa 100644 >--- a/t/db_dependent/Koha/Item/Transfers.t >+++ b/t/db_dependent/Koha/Item/Transfers.t >@@ -35,11 +35,16 @@ $schema->storage->txn_begin; > my $builder = t::lib::TestBuilder->new; > my $library_from = $builder->build( { source => 'Branch' } ); > my $library_to = $builder->build( { source => 'Branch' } ); >-my $item = $builder->build( { source => 'Item', value => { holding_branch => $library_from->{branchcode}, homebranch => $library_to->{branchcode} } } ); >+my $item = $builder->build_sample_item( >+ { >+ holdingbranch => $library_from->{branchcode}, >+ homebranch => $library_to->{branchcode} >+ } >+); > > my $nb_of_transfers = Koha::Item::Transfers->search->count; > my $new_transfer_1 = Koha::Item::Transfer->new( >- { itemnumber => $item->{itemnumber}, >+ { itemnumber => $item->itemnumber, > frombranch => $library_from->{branchcode}, > tobranch => $library_to->{branchcode}, > datearrived => dt_from_string, >@@ -47,7 +52,7 @@ my $new_transfer_1 = Koha::Item::Transfer->new( > } > )->store; > my $new_transfer_2 = Koha::Item::Transfer->new( >- { itemnumber => $item->{itemnumber}, >+ { itemnumber => $item->itemnumber, > frombranch => $library_from->{branchcode}, > tobranch => $library_to->{branchcode}, > datearrived => undef, >@@ -74,20 +79,17 @@ subtest 'daterequested tests' => sub { > $schema->storage->txn_begin; > my $library_from = $builder->build( { source => 'Branch' } ); > my $library_to = $builder->build( { source => 'Branch' } ); >- my $item = $builder->build( >+ my $item = $builder->build_sample_item( > { >- source => 'Item', >- value => { >- holding_branch => $library_from->{branchcode}, >- homebranch => $library_to->{branchcode} >- } >+ holdingbranch => $library_from->{branchcode}, >+ homebranch => $library_to->{branchcode} > } > ); > > my $now = dt_from_string; > my $transfer = Koha::Item::Transfer->new( > { >- itemnumber => $item->{itemnumber}, >+ itemnumber => $item->itemnumber, > frombranch => $library_from->{branchcode}, > tobranch => $library_to->{branchcode} > } >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index 4f434adc3c..1448b07a8d 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -271,28 +271,16 @@ subtest 'siblings' => sub { > subtest 'has_overdues' => sub { > plan tests => 3; > >- my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } ); >- my $item_1 = $builder->build( >- { source => 'Item', >- value => { >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- notforloan => 0, >- itemlost => 0, >- withdrawn => 0, >- biblionumber => $biblioitem_1->{biblionumber} >- } >- } >- ); >+ my $item_1 = $builder->build_sample_item; > my $retrieved_patron = Koha::Patrons->find( $new_patron_1->borrowernumber ); > is( $retrieved_patron->has_overdues, 0, ); > > my $tomorrow = DateTime->today( time_zone => C4::Context->tz() )->add( days => 1 ); >- my $issue = Koha::Checkout->new({ borrowernumber => $new_patron_1->id, itemnumber => $item_1->{itemnumber}, date_due => $tomorrow, branchcode => $library->{branchcode} })->store(); >+ my $issue = Koha::Checkout->new({ borrowernumber => $new_patron_1->id, itemnumber => $item_1->itemnumber, date_due => $tomorrow, branchcode => $library->{branchcode} })->store(); > is( $retrieved_patron->has_overdues, 0, ); > $issue->delete(); > my $yesterday = DateTime->today(time_zone => C4::Context->tz())->add( days => -1 ); >- $issue = Koha::Checkout->new({ borrowernumber => $new_patron_1->id, itemnumber => $item_1->{itemnumber}, date_due => $yesterday, branchcode => $library->{branchcode} })->store(); >+ $issue = Koha::Checkout->new({ borrowernumber => $new_patron_1->id, itemnumber => $item_1->itemnumber, date_due => $yesterday, branchcode => $library->{branchcode} })->store(); > $retrieved_patron = Koha::Patrons->find( $new_patron_1->borrowernumber ); > is( $retrieved_patron->has_overdues, 1, ); > $issue->delete(); >@@ -579,41 +567,23 @@ subtest 'checkouts + pending_checkouts + get_overdues + old_checkouts' => sub { > > my $library = $builder->build( { source => 'Branch' } ); > my ($biblionumber_1) = AddBiblio( MARC::Record->new, '' ); >- my $item_1 = $builder->build( >+ my $item_1 = $builder->build_sample_item( > { >- source => 'Item', >- value => { >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- biblionumber => $biblionumber_1, >- itemlost => 0, >- withdrawn => 0, >- } >+ library => $library->{branchcode}, >+ biblionumber => $biblionumber_1, > } > ); >- my $item_2 = $builder->build( >+ my $item_2 = $builder->build_sample_item( > { >- source => 'Item', >- value => { >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- biblionumber => $biblionumber_1, >- itemlost => 0, >- withdrawn => 0, >- } >+ library => $library->{branchcode}, >+ biblionumber => $biblionumber_1, > } > ); > my ($biblionumber_2) = AddBiblio( MARC::Record->new, '' ); >- my $item_3 = $builder->build( >+ my $item_3 = $builder->build_sample_item( > { >- source => 'Item', >- value => { >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- biblionumber => $biblionumber_2, >- itemlost => 0, >- withdrawn => 0, >- } >+ library => $library->{branchcode}, >+ biblionumber => $biblionumber_2, > } > ); > my $patron = $builder->build( >@@ -639,9 +609,9 @@ subtest 'checkouts + pending_checkouts + get_overdues + old_checkouts' => sub { > > t::lib::Mocks::mock_userenv({ branchcode => $library->{branchcode} }); > >- AddIssue( $patron, $item_1->{barcode}, DateTime->now->subtract( days => 1 ) ); >- AddIssue( $patron, $item_2->{barcode}, DateTime->now->subtract( days => 5 ) ); >- AddIssue( $patron, $item_3->{barcode} ); >+ AddIssue( $patron, $item_1->barcode, DateTime->now->subtract( days => 1 ) ); >+ AddIssue( $patron, $item_2->barcode, DateTime->now->subtract( days => 5 ) ); >+ AddIssue( $patron, $item_3->barcode ); > > $patron = Koha::Patrons->find( $patron->{borrowernumber} ); > $checkouts = $patron->checkouts; >@@ -652,17 +622,17 @@ subtest 'checkouts + pending_checkouts + get_overdues + old_checkouts' => sub { > is( ref($pending_checkouts), 'Koha::Checkouts', 'pending_checkouts should return a Koha::Checkouts object' ); > > my $first_checkout = $pending_checkouts->next; >- is( $first_checkout->unblessed_all_relateds->{biblionumber}, $item_3->{biblionumber}, 'pending_checkouts should prefetch values from other tables (here biblio)' ); >+ is( $first_checkout->unblessed_all_relateds->{biblionumber}, $item_3->biblionumber, 'pending_checkouts should prefetch values from other tables (here biblio)' ); > > my $overdues = $patron->get_overdues; > is( $overdues->count, 2, 'Patron should have 2 overdues'); > is( ref($overdues), 'Koha::Checkouts', 'Koha::Patron->get_overdues should return Koha::Checkouts' ); >- is( $overdues->next->itemnumber, $item_1->{itemnumber}, 'The issue should be returned in the same order as they have been done, first is correct' ); >- is( $overdues->next->itemnumber, $item_2->{itemnumber}, 'The issue should be returned in the same order as they have been done, second is correct' ); >+ is( $overdues->next->itemnumber, $item_1->itemnumber, 'The issue should be returned in the same order as they have been done, first is correct' ); >+ is( $overdues->next->itemnumber, $item_2->itemnumber, 'The issue should be returned in the same order as they have been done, second is correct' ); > > >- C4::Circulation::AddReturn( $item_1->{barcode} ); >- C4::Circulation::AddReturn( $item_2->{barcode} ); >+ C4::Circulation::AddReturn( $item_1->barcode ); >+ C4::Circulation::AddReturn( $item_2->barcode ); > $old_checkouts = $patron->old_checkouts; > is( $old_checkouts->count, 2, 'old_checkouts should return 2 old checkouts that patron' ); > is( ref($old_checkouts), 'Koha::Old::Checkouts', 'old_checkouts should return a Koha::Old::Checkouts object' ); >@@ -968,37 +938,26 @@ subtest 'holds and old_holds' => sub { > > my $library = $builder->build( { source => 'Branch' } ); > my ($biblionumber_1) = AddBiblio( MARC::Record->new, '' ); >- my $item_1 = $builder->build( >+ my $item_1 = $builder->build_sample_item( > { >- source => 'Item', >- value => { >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- biblionumber => $biblionumber_1 >- } >+ library => $library->{branchcode}, >+ biblionumber => $biblionumber_1, > } > ); >- my $item_2 = $builder->build( >+ my $item_2 = $builder->build_sample_item( > { >- source => 'Item', >- value => { >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- biblionumber => $biblionumber_1 >- } >+ library => $library->{branchcode}, >+ biblionumber => $biblionumber_1, > } > ); > my ($biblionumber_2) = AddBiblio( MARC::Record->new, '' ); >- my $item_3 = $builder->build( >+ my $item_3 = $builder->build_sample_item( > { >- source => 'Item', >- value => { >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- biblionumber => $biblionumber_2 >- } >+ library => $library->{branchcode}, >+ biblionumber => $biblionumber_2, > } > ); >+ > my $patron = $builder->build( > { > source => 'Borrower', >@@ -1086,41 +1045,27 @@ subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub { > value => { privacy => 1, } > } > ); >- my $item_1 = $builder->build( >- { source => 'Item', >- value => { >- itemlost => 0, >- withdrawn => 0, >- }, >- } >- ); >+ my $item_1 = $builder->build_sample_item; > my $issue_1 = $builder->build( > { source => 'Issue', > value => { > borrowernumber => $patron->{borrowernumber}, >- itemnumber => $item_1->{itemnumber}, >- }, >- } >- ); >- my $item_2 = $builder->build( >- { source => 'Item', >- value => { >- itemlost => 0, >- withdrawn => 0, >+ itemnumber => $item_1->itemnumber, > }, > } > ); >+ my $item_2 = $builder->build_sample_item; > my $issue_2 = $builder->build( > { source => 'Issue', > value => { > borrowernumber => $patron->{borrowernumber}, >- itemnumber => $item_2->{itemnumber}, >+ itemnumber => $item_2->itemnumber, > }, > } > ); > >- my ( $returned_1, undef, undef ) = C4::Circulation::AddReturn( $item_1->{barcode}, undef, undef, dt_from_string('2010-10-10') ); >- my ( $returned_2, undef, undef ) = C4::Circulation::AddReturn( $item_2->{barcode}, undef, undef, dt_from_string('2011-11-11') ); >+ my ( $returned_1, undef, undef ) = C4::Circulation::AddReturn( $item_1->barcode, undef, undef, dt_from_string('2010-10-10') ); >+ my ( $returned_2, undef, undef ) = C4::Circulation::AddReturn( $item_2->barcode, undef, undef, dt_from_string('2011-11-11') ); > is( $returned_1 && $returned_2, 1, 'The items should have been returned' ); > > my $patrons_to_anonymise = Koha::Patrons->search_patrons_to_anonymise( { before => '2010-10-11' } )->search( { 'me.borrowernumber' => $patron->{borrowernumber} } ); >@@ -1134,26 +1079,26 @@ subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub { > > my $dbh = C4::Context->dbh; > my $sth = $dbh->prepare(q|SELECT borrowernumber FROM old_issues where itemnumber = ?|); >- $sth->execute($item_1->{itemnumber}); >+ $sth->execute($item_1->itemnumber); > my ($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; > is( $borrowernumber_used_to_anonymised, $anonymous->{borrowernumber}, 'With privacy=1, the issue should have been anonymised' ); >- $sth->execute($item_2->{itemnumber}); >+ $sth->execute($item_2->itemnumber); > ($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; > is( $borrowernumber_used_to_anonymised, $patron->{borrowernumber}, 'The issue should not have been anonymised, the returned date is later' ); > > $rows_affected = Koha::Patrons->search_patrons_to_anonymise( { before => '2011-11-12' } )->anonymise_issue_history; >- $sth->execute($item_2->{itemnumber}); >+ $sth->execute($item_2->itemnumber); > ($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; > is( $borrowernumber_used_to_anonymised, $anonymous->{borrowernumber}, 'The issue should have been anonymised, the returned date is before' ); > > my $sth_reset = $dbh->prepare(q|UPDATE old_issues SET borrowernumber = ? WHERE itemnumber = ?|); >- $sth_reset->execute( $patron->{borrowernumber}, $item_1->{itemnumber} ); >- $sth_reset->execute( $patron->{borrowernumber}, $item_2->{itemnumber} ); >+ $sth_reset->execute( $patron->{borrowernumber}, $item_1->itemnumber ); >+ $sth_reset->execute( $patron->{borrowernumber}, $item_2->itemnumber ); > $rows_affected = Koha::Patrons->search_patrons_to_anonymise->anonymise_issue_history; >- $sth->execute($item_1->{itemnumber}); >+ $sth->execute($item_1->itemnumber); > ($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; > is( $borrowernumber_used_to_anonymised, $anonymous->{borrowernumber}, 'The issue 1 should have been anonymised, before parameter was not passed' ); >- $sth->execute($item_2->{itemnumber}); >+ $sth->execute($item_2->itemnumber); > ($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; > is( $borrowernumber_used_to_anonymised, $anonymous->{borrowernumber}, 'The issue 2 should have been anonymised, before parameter was not passed' ); > >@@ -1169,30 +1114,23 @@ subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub { > value => { privacy => 0, } > } > ); >- my $item = $builder->build( >- { source => 'Item', >- value => { >- itemlost => 0, >- withdrawn => 0, >- }, >- } >- ); >+ my $item = $builder->build_sample_item; > my $issue = $builder->build( > { source => 'Issue', > value => { > borrowernumber => $patron->{borrowernumber}, >- itemnumber => $item->{itemnumber}, >+ itemnumber => $item->itemnumber, > }, > } > ); > >- my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, dt_from_string('2010-10-10') ); >+ my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->barcode, undef, undef, dt_from_string('2010-10-10') ); > is( $returned, 1, 'The item should have been returned' ); > > my $dbh = C4::Context->dbh; > my ($borrowernumber_used_to_anonymised) = $dbh->selectrow_array(q| > SELECT borrowernumber FROM old_issues where itemnumber = ? >- |, undef, $item->{itemnumber}); >+ |, undef, $item->itemnumber); > is( $borrowernumber_used_to_anonymised, $patron->{borrowernumber}, 'With privacy=0, the issue should not be anonymised' ); > Koha::Patrons->find( $patron->{borrowernumber})->delete; > }; >@@ -1208,24 +1146,17 @@ subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub { > value => { privacy => 1, } > } > ); >- my $item = $builder->build( >- { source => 'Item', >- value => { >- itemlost => 0, >- withdrawn => 0, >- }, >- } >- ); >+ my $item = $builder->build_sample_item; > my $issue = $builder->build( > { source => 'Issue', > value => { > borrowernumber => $patron->{borrowernumber}, >- itemnumber => $item->{itemnumber}, >+ itemnumber => $item->itemnumber, > }, > } > ); > >- my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, dt_from_string('2010-10-10') ); >+ my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->barcode, undef, undef, dt_from_string('2010-10-10') ); > is( $returned, 1, 'The item should have been returned' ); > my $rows_affected = Koha::Patrons->search_patrons_to_anonymise( { before => '2010-10-11' } )->anonymise_issue_history( { before => '2010-10-11' } ); > ok( $rows_affected > 0, 'AnonymiseIssueHistory should affect at least 1 row' ); >@@ -1233,7 +1164,7 @@ subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub { > my $dbh = C4::Context->dbh; > my ($borrowernumber_used_to_anonymised) = $dbh->selectrow_array(q| > SELECT borrowernumber FROM old_issues where itemnumber = ? >- |, undef, $item->{itemnumber}); >+ |, undef, $item->itemnumber); > is( $borrowernumber_used_to_anonymised, undef, 'With AnonymousPatron is not defined, the issue should have been anonymised anyway' ); > Koha::Patrons->find( $patron->{borrowernumber})->delete; > }; >@@ -1246,24 +1177,17 @@ subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub { > value => { privacy => 1 } # Another branchcode than the logged in librarian > } > ); >- my $item = $builder->build( >- { source => 'Item', >- value => { >- itemlost => 0, >- withdrawn => 0, >- }, >- } >- ); >+ my $item = $builder->build_sample_item; > my $issue = $builder->build( > { source => 'Issue', > value => { > borrowernumber => $patron->{borrowernumber}, >- itemnumber => $item->{itemnumber}, >+ itemnumber => $item->itemnumber, > }, > } > ); > >- my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, dt_from_string('2010-10-10') ); >+ my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->barcode, undef, undef, dt_from_string('2010-10-10') ); > is( Koha::Patrons->search_patrons_to_anonymise( { before => '2010-10-11' } )->count, 0 ); > Koha::Patrons->find( $patron->{borrowernumber})->delete; > }; >@@ -1471,37 +1395,26 @@ subtest 'get_overdues' => sub { > > my $library = $builder->build( { source => 'Branch' } ); > my ($biblionumber_1) = AddBiblio( MARC::Record->new, '' ); >- my $item_1 = $builder->build( >+ my $item_1 = $builder->build_sample_item( > { >- source => 'Item', >- value => { >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- biblionumber => $biblionumber_1 >- } >+ library => $library->{branchcode}, >+ biblionumber => $biblionumber_1, > } > ); >- my $item_2 = $builder->build( >+ my $item_2 = $builder->build_sample_item( > { >- source => 'Item', >- value => { >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- biblionumber => $biblionumber_1 >- } >+ library => $library->{branchcode}, >+ biblionumber => $biblionumber_1, > } > ); > my ($biblionumber_2) = AddBiblio( MARC::Record->new, '' ); >- my $item_3 = $builder->build( >+ my $item_3 = $builder->build_sample_item( > { >- source => 'Item', >- value => { >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- biblionumber => $biblionumber_2 >- } >+ library => $library->{branchcode}, >+ biblionumber => $biblionumber_2, > } > ); >+ > my $patron = $builder->build( > { > source => 'Borrower', >@@ -1511,15 +1424,15 @@ subtest 'get_overdues' => sub { > > t::lib::Mocks::mock_preference({ branchcode => $library->{branchcode} }); > >- AddIssue( $patron, $item_1->{barcode}, DateTime->now->subtract( days => 1 ) ); >- AddIssue( $patron, $item_2->{barcode}, DateTime->now->subtract( days => 5 ) ); >- AddIssue( $patron, $item_3->{barcode} ); >+ AddIssue( $patron, $item_1->barcode, DateTime->now->subtract( days => 1 ) ); >+ AddIssue( $patron, $item_2->barcode, DateTime->now->subtract( days => 5 ) ); >+ AddIssue( $patron, $item_3->barcode ); > > $patron = Koha::Patrons->find( $patron->{borrowernumber} ); > my $overdues = $patron->get_overdues; > is( $overdues->count, 2, 'Patron should have 2 overdues'); >- is( $overdues->next->itemnumber, $item_1->{itemnumber}, 'The issue should be returned in the same order as they have been done, first is correct' ); >- is( $overdues->next->itemnumber, $item_2->{itemnumber}, 'The issue should be returned in the same order as they have been done, second is correct' ); >+ is( $overdues->next->itemnumber, $item_1->itemnumber, 'The issue should be returned in the same order as they have been done, first is correct' ); >+ is( $overdues->next->itemnumber, $item_2->itemnumber, 'The issue should be returned in the same order as they have been done, second is correct' ); > > my $o = $overdues->reset->next; > my $unblessed_overdue = $o->unblessed_all_relateds; >diff --git a/t/db_dependent/Koha/Ratings.t b/t/db_dependent/Koha/Ratings.t >index 00229e0d82..faeed42720 100755 >--- a/t/db_dependent/Koha/Ratings.t >+++ b/t/db_dependent/Koha/Ratings.t >@@ -31,8 +31,8 @@ my $builder = t::lib::TestBuilder->new; > > my $patron_1 = $builder->build( { source => 'Borrower', } ); > my $patron_2 = $builder->build( { source => 'Borrower', } ); >-my $biblio_1 = $builder->build( { source => 'Biblio', } ); >-my $biblionumber = $biblio_1->{biblionumber}; >+my $biblio_1 = $builder->build_sample_biblio; >+my $biblionumber = $biblio_1->biblionumber; > > my $rating_1 = Koha::Rating->new( { biblionumber => $biblionumber, borrowernumber => $patron_1->{borrowernumber}, rating_value => 3 } )->store; > my $rating_2 = Koha::Rating->new( { biblionumber => $biblionumber, borrowernumber => $patron_2->{borrowernumber}, rating_value => 4 } )->store; >diff --git a/t/db_dependent/Koha/Reviews.t b/t/db_dependent/Koha/Reviews.t >index 9a51775ebb..7e947a1bb8 100644 >--- a/t/db_dependent/Koha/Reviews.t >+++ b/t/db_dependent/Koha/Reviews.t >@@ -36,23 +36,23 @@ my $patron_1 = $builder->build({ source => 'Borrower', value => { flags => undef > my $patron_2 = $builder->build({ source => 'Borrower' }); > $patron_1 = Koha::Patrons->find( $patron_1->{borrowernumber} ); > $patron_2 = Koha::Patrons->find( $patron_2->{borrowernumber} ); >-my $biblio_1 = $builder->build({ source => 'Biblio' }); >-my $biblio_2 = $builder->build({ source => 'Biblio' }); >+my $biblio_1 = $builder->build_sample_biblio; >+my $biblio_2 = $builder->build_sample_biblio; > my $nb_of_reviews = Koha::Reviews->search->count; > my $nb_of_approved_reviews = Koha::Reviews->search({ approved => 1 })->count; > my $new_review_1_1 = Koha::Review->new({ > borrowernumber => $patron_1->borrowernumber, >- biblionumber => $biblio_1->{biblionumber}, >+ biblionumber => $biblio_1->biblionumber, > review => 'a kind review', > })->store; > my $new_review_1_2 = Koha::Review->new({ > borrowernumber => $patron_1->borrowernumber, >- biblionumber => $biblio_2->{biblionumber}, >+ biblionumber => $biblio_2->biblionumber, > review => 'anoter kind review', > })->store; > my $new_review_2_1 = Koha::Review->new({ > borrowernumber => $patron_2->borrowernumber, >- biblionumber => $biblio_1->{biblionumber}, >+ biblionumber => $biblio_1->biblionumber, > review => 'just anoter review', > })->store; > >diff --git a/t/db_dependent/Koha/SharedContent.t b/t/db_dependent/Koha/SharedContent.t >index 462a27223f..fab02d4170 100644 >--- a/t/db_dependent/Koha/SharedContent.t >+++ b/t/db_dependent/Koha/SharedContent.t >@@ -125,16 +125,7 @@ my $loggedinuser = $builder->build_object({ > } > }); > >-my $biblio = $builder->build({ >- source => 'Biblio', >-}); >- >-my $biblioitem = $builder->build({ >- source => 'Biblioitem', >- value => { >- biblionumber => $biblio->{biblionumber} >- } >-}); >+my $biblio = $builder->build_sample_biblio; > > my $subscriptionFrequency = $builder->build({ > source => 'SubscriptionFrequency' >@@ -147,7 +138,7 @@ my $subscriptionNumberpattern = $builder->build({ > my $subscription = $builder->build({ > source => 'Subscription', > value => { >- biblionumber => $biblio->{biblionumber}, >+ biblionumber => $biblio->biblionumber, > periodicity => $subscriptionFrequency->{id}, > numberpattern => $subscriptionNumberpattern->{id}, > mana_id => undef >@@ -178,7 +169,7 @@ my $data = Koha::SharedContent::prepare_entity_data( > > is($data->{language}, 'en', 'Language is set to default'); > is($data->{exportemail}, $library->branchemail, 'Email is set with the userenv branch one'); >-is($data->{title}, $biblio->{title}, 'Shared title'); >+is($data->{title}, $biblio->title, 'Shared title'); > is($data->{sfdescription}, $subscriptionFrequency->{description}, 'Shared sfdescription'); > is($data->{unit}, $subscriptionFrequency->{unit}, 'Shared unit'); > is($data->{unitsperissue}, $subscriptionFrequency->{unitsperissue}, 'Shared unitsperissue'); >@@ -193,9 +184,10 @@ is($data->{every1}, $subscriptionNumberpattern->{every1}, 'Shared every1'); > is($data->{whenmorethan1}, $subscriptionNumberpattern->{whenmorethan1}, 'Shared whenmorethan1'); > is($data->{setto1}, $subscriptionNumberpattern->{setto1}, 'Shared setto1'); > is($data->{numbering1}, $subscriptionNumberpattern->{numbering1}, 'Shared numbering1'); >-is($data->{issn}, $biblioitem->{issn}, 'Shared ISSN'); >-is($data->{ean}, $biblioitem->{ean}, 'Shared EAN'); >-is($data->{publishercode}, $biblioitem->{publishercode}, 'Shared publishercode'); >+my $biblioitem = $biblio->biblioitem; >+is($data->{issn}, $biblioitem->issn, 'Shared ISSN'); >+is($data->{ean}, $biblioitem->ean, 'Shared EAN'); >+is($data->{publishercode}, $biblioitem->publishercode, 'Shared publishercode'); > > sub mock_response { > my $response = Test::MockObject->new(); >diff --git a/t/db_dependent/Koha/Subscription.t b/t/db_dependent/Koha/Subscription.t >index 926bdc198c..6765640d38 100644 >--- a/t/db_dependent/Koha/Subscription.t >+++ b/t/db_dependent/Koha/Subscription.t >@@ -107,22 +107,15 @@ subtest 'Koha::Subscription->frequency' => sub { > }; > > my $nb_of_subs = Koha::Subscriptions->search->count; >-my $biblio_1 = $builder->build( { source => 'Biblio' } ); >-my $bi_1 = $builder->build( >- { >- source => 'Biblioitem', >- value => { >- biblionumber => $biblio_1->{biblionumber} >- } >- } >-); >+my $biblio_1 = $builder->build_sample_biblio; >+my $bi_1 = $biblio_1->biblioitem; > my $sub_freq_1 = $builder->build( { source => 'SubscriptionFrequency' } ); > my $sub_np_1 = $builder->build( { source => 'SubscriptionNumberpattern' } ); > my $sub_1 = $builder->build( > { > source => 'Subscription', > value => { >- biblionumber => $biblio_1->{biblionumber}, >+ biblionumber => $biblio_1->biblionumber, > periodicity => $sub_freq_1->{id}, > numberpattern => $sub_np_1->{id} > } >@@ -136,7 +129,7 @@ is( > ); > is( > $sub_1->{biblionumber}, >- $biblio_1->{biblionumber}, >+ $biblio_1->biblionumber, > 'The link between sub and biblio is well done' > ); > is( $sub_1->{periodicity}, $sub_freq_1->{id}, >@@ -146,7 +139,7 @@ is( $sub_1->{numberpattern}, > 'The link between sub and sub_numberpattern is well done' ); > > my $ref = { >- 'title' => $biblio_1->{title}, >+ 'title' => $biblio_1->title, > 'sfdescription' => $sub_freq_1->{description}, > 'unit' => $sub_freq_1->{unit}, > 'unitsperissue' => $sub_freq_1->{unitsperissue}, >@@ -173,9 +166,9 @@ my $ref = { > 'whenmorethan3' => $sub_np_1->{whenmorethan3}, > 'setto3' => $sub_np_1->{setto3}, > 'numbering3' => $sub_np_1->{numbering3}, >- 'issn' => $bi_1->{issn}, >- 'ean' => $bi_1->{ean}, >- 'publishercode' => $bi_1->{publishercode} >+ 'issn' => $bi_1->issn, >+ 'ean' => $bi_1->ean, >+ 'publishercode' => $bi_1->publishercode, > }; > > is_deeply( Koha::Subscription->get_sharable_info( $sub_1->{subscriptionid} ), >diff --git a/t/db_dependent/Koha/Suggestions.t b/t/db_dependent/Koha/Suggestions.t >index f4c4974548..6afdb8349d 100644 >--- a/t/db_dependent/Koha/Suggestions.t >+++ b/t/db_dependent/Koha/Suggestions.t >@@ -33,18 +33,18 @@ my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; > > my $builder = t::lib::TestBuilder->new; >-my $biblio_1 = $builder->build( { source => 'Biblio' } ); >-my $biblio_2 = $builder->build( { source => 'Biblio' } ); >+my $biblio_1 = $builder->build_sample_biblio; >+my $biblio_2 = $builder->build_sample_biblio; > my $patron = $builder->build( { source => 'Borrower' } ); > my $nb_of_suggestions = Koha::Suggestions->search->count; > my $new_suggestion_1 = Koha::Suggestion->new( > { suggestedby => $patron->{borrowernumber}, >- biblionumber => $biblio_1->{biblionumber}, >+ biblionumber => $biblio_1->biblionumber, > } > )->store; > my $new_suggestion_2 = Koha::Suggestion->new( > { suggestedby => $patron->{borrowernumber}, >- biblionumber => $biblio_2->{biblionumber}, >+ biblionumber => $biblio_2->biblionumber, > } > )->store; > >@@ -52,7 +52,7 @@ subtest 'store' => sub { > plan tests => 3; > my $suggestion = Koha::Suggestion->new( > { suggestedby => $patron->{borrowernumber}, >- biblionumber => $biblio_1->{biblionumber}, >+ biblionumber => $biblio_1->biblionumber, > } > )->store; > >diff --git a/t/db_dependent/Koha/Z3950Responder/Session.t b/t/db_dependent/Koha/Z3950Responder/Session.t >index 33bfd4f527..a3735f32e0 100644 >--- a/t/db_dependent/Koha/Z3950Responder/Session.t >+++ b/t/db_dependent/Koha/Z3950Responder/Session.t >@@ -20,34 +20,24 @@ subtest 'add_item_status' => sub { > plan tests => 2; > > ## FIRST ITEM HAS ALL THE STATUSES ## >- my $item_1 = $builder->build({ >- source => 'Item', >- value => { >- onloan => '2017-07-07', >- itemlost => 1, >+ my $item_1 = $builder->build_sample_item( >+ { >+ onloan => '2017-07-07', >+ itemlost => 1, > notforloan => 1, >- damaged => 1, >- withdrawn => 1, >+ damaged => 1, >+ withdrawn => 1, > } >- }); >- my $item_marc_1 = C4::Items::GetMarcItem( $item_1->{biblionumber}, $item_1->{itemnumber} ); >+ ); >+ my $item_marc_1 = C4::Items::GetMarcItem( $item_1->biblionumber, $item_1->itemnumber ); > my $item_field_1 = scalar $item_marc_1->field('952'); >- $builder->build({ source => 'Reserve', value=> { itemnumber => $item_1->{itemnumber} } }); >- $builder->build({ source => 'Branchtransfer', value=> { itemnumber => $item_1->{itemnumber}, datearrived => undef } }); >+ $builder->build({ source => 'Reserve', value=> { itemnumber => $item_1->itemnumber } }); >+ $builder->build({ source => 'Branchtransfer', value=> { itemnumber => $item_1->itemnumber, datearrived => undef } }); > ## END FIRST ITEM ## > > ## SECOND ITEM HAS NO STATUSES ## >- my $item_2 = $builder->build({ >- source => 'Item', >- value => { >- onloan => undef, >- itemlost => 0, >- notforloan => 0, >- damaged => 0, >- withdrawn => 0, >- } >- }); >- my $item_marc_2 = C4::Items::GetMarcItem( $item_2->{biblionumber}, $item_2->{itemnumber} ); >+ my $item_2 = $builder->build_sample_item; >+ my $item_marc_2 = C4::Items::GetMarcItem( $item_2->biblionumber, $item_2->itemnumber ); > my $item_field_2 = scalar $item_marc_2->field('952'); > ## END SECOND ITEM ## > >diff --git a/t/db_dependent/Koha/Z3950Responder/Session2.t b/t/db_dependent/Koha/Z3950Responder/Session2.t >index ece9bded6f..ec1e00b0c5 100644 >--- a/t/db_dependent/Koha/Z3950Responder/Session2.t >+++ b/t/db_dependent/Koha/Z3950Responder/Session2.t >@@ -44,34 +44,24 @@ subtest 'add_item_status' => sub { > }); > > ## FIRST ITEM HAS ALL THE STATUSES ## >- my $item_1 = $builder->build({ >- source => 'Item', >- value => { >- onloan => '2017-07-07', >- itemlost => 1, >+ my $item_1 = $builder->build_sample_item( >+ { >+ onloan => '2017-07-07', >+ itemlost => 1, > notforloan => 1, >- damaged => 1, >- withdrawn => 1, >+ damaged => 1, >+ withdrawn => 1, > } >- }); >- my $item_marc_1 = C4::Items::GetMarcItem( $item_1->{biblionumber}, $item_1->{itemnumber} ); >+ ); >+ my $item_marc_1 = C4::Items::GetMarcItem( $item_1->biblionumber, $item_1->itemnumber ); > my $item_field_1 = scalar $item_marc_1->field('952'); >- $builder->build({ source => 'Reserve', value=> { itemnumber => $item_1->{itemnumber} } }); >- $builder->build({ source => 'Branchtransfer', value=> { itemnumber => $item_1->{itemnumber}, datearrived => undef } }); >+ $builder->build({ source => 'Reserve', value=> { itemnumber => $item_1->itemnumber } }); >+ $builder->build({ source => 'Branchtransfer', value=> { itemnumber => $item_1->itemnumber, datearrived => undef } }); > ## END FIRST ITEM ## > > ## SECOND ITEM HAS NO STATUSES ## >- my $item_2 = $builder->build({ >- source => 'Item', >- value => { >- onloan => undef, >- itemlost => 0, >- notforloan => 0, >- damaged => 0, >- withdrawn => 0, >- } >- }); >- my $item_marc_2 = C4::Items::GetMarcItem( $item_2->{biblionumber}, $item_2->{itemnumber} ); >+ my $item_2 = $builder->build_sample_item; >+ my $item_marc_2 = C4::Items::GetMarcItem( $item_2->biblionumber, $item_2->itemnumber ); > my $item_field_2 = scalar $item_marc_2->field('952'); > ## END SECOND ITEM ## > >diff --git a/t/db_dependent/Letters/TemplateToolkit.t b/t/db_dependent/Letters/TemplateToolkit.t >index e886b23ee1..95f1463a23 100644 >--- a/t/db_dependent/Letters/TemplateToolkit.t >+++ b/t/db_dependent/Letters/TemplateToolkit.t >@@ -292,45 +292,36 @@ subtest 'regression tests' => sub { > > my $library = $builder->build( { source => 'Branch' } ); > my $patron = $builder->build( { source => 'Borrower' } ); >- my $biblio1 = Koha::Biblio->new({title => 'Test Biblio 1', author => 'An author', })->store->unblessed; >- my $biblioitem1 = Koha::Biblioitem->new({biblionumber => $biblio1->{biblionumber}})->store()->unblessed; >- my $item1 = Koha::Item->new( >+ my $item1 = $builder->build_sample_item( > { >- biblionumber => $biblio1->{biblionumber}, >- biblioitemnumber => $biblioitem1->{biblioitemnumber}, >- barcode => 'a_t_barcode', >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- itype => 'BK', >- itemcallnumber => 'itemcallnumber1', >+ barcode => 'a_t_barcode', >+ library => $library->{branchcode}, >+ itype => 'BK', >+ itemcallnumber => 'itemcallnumber1', > } >- )->store->unblessed; >- my $biblio2 = Koha::Biblio->new({title => 'Test Biblio 2'})->store->unblessed; >- my $biblioitem2 = Koha::Biblioitem->new({biblionumber => $biblio2->{biblionumber}})->store()->unblessed; >- my $item2 = Koha::Item->new( >+ ); >+ my $biblio1 = $item1->biblio->unblessed; >+ $item1 = $item1->unblessed; >+ my $item2 = $builder->build_sample_item( > { >- biblionumber => $biblio2->{biblionumber}, >- biblioitemnumber => $biblioitem2->{biblioitemnumber}, >- barcode => 'another_t_barcode', >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- itype => 'BK', >- itemcallnumber => 'itemcallnumber2', >+ barcode => 'another_t_barcode', >+ library => $library->{branchcode}, >+ itype => 'BK', >+ itemcallnumber => 'itemcallnumber2', > } >- )->store->unblessed; >- my $biblio3 = Koha::Biblio->new({title => 'Test Biblio 3'})->store->unblessed; >- my $biblioitem3 = Koha::Biblioitem->new({biblionumber => $biblio3->{biblionumber}})->store()->unblessed; >- my $item3 = Koha::Item->new( >+ ); >+ my $biblio2 = $item2->biblio->unblessed; >+ $item2 = $item2->unblessed; >+ my $item3 = $builder->build_sample_item( > { >- biblionumber => $biblio3->{biblionumber}, >- biblioitemnumber => $biblioitem3->{biblioitemnumber}, >- barcode => 'another_t_barcode_3', >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- itype => 'BK', >- itemcallnumber => 'itemcallnumber3', >+ barcode => 'another_t_barcode_3', >+ library => $library->{branchcode}, >+ itype => 'BK', >+ itemcallnumber => 'itemcallnumber3', > } >- )->store->unblessed; >+ ); >+ my $biblio3 = $item3->biblio->unblessed; >+ $item3 = $item3->unblessed; > > t::lib::Mocks::mock_userenv({ branchcode => $library->{branchcode} }); > >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index 376737f5f6..26f1f4863e 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -87,10 +87,7 @@ my $bibnum = $builder->build_sample_biblio({frameworkcode => $frameworkcode})->b > # Create a helper item instance for testing > my $item = $builder->build_sample_item({ biblionumber => $bibnum, library => $branch_1, itype => $itemtype }); > >-my $biblio_with_no_item = $builder->build({ >- source => 'Biblio' >-}); >- >+my $biblio_with_no_item = $builder->build_sample_biblio; > > # Modify item; setting barcode. > my $testbarcode = '97531'; >@@ -601,7 +598,7 @@ Koha::Patrons->find( $borrowernumber )->set({ dateofbirth => $borrower->{dateofb > > is( C4::Reserves::CanBookBeReserved($borrowernumber, $biblionumber)->{status} , 'OK', "Reserving a 'PEGI 16' Biblio by a 30 year old borrower succeeds"); > >-is( C4::Reserves::CanBookBeReserved($borrowernumber, $biblio_with_no_item->{biblionumber})->{status} , '', "Biblio with no item. Status is empty"); >+is( C4::Reserves::CanBookBeReserved($borrowernumber, $biblio_with_no_item->biblionumber)->{status} , '', "Biblio with no item. Status is empty"); > #### > ####### EO Bug 13113 <<< > #### >diff --git a/t/db_dependent/Reserves/CancelExpiredReserves.t b/t/db_dependent/Reserves/CancelExpiredReserves.t >index e8f8df8cef..51cb2b05c2 100644 >--- a/t/db_dependent/Reserves/CancelExpiredReserves.t >+++ b/t/db_dependent/Reserves/CancelExpiredReserves.t >@@ -111,10 +111,8 @@ subtest 'Test handling of waiting reserves by CancelExpiredReserves' => sub { > my $builder = t::lib::TestBuilder->new(); > my $category = $builder->build({ source => 'Category' }); > my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode }; >- my $biblio = $builder->build({ source => 'Biblio' }); >- my $bibnum = $biblio->{biblionumber}; >- my $item = $builder->build({ source => 'Item', value => { biblionumber => $bibnum }}); >- my $itemnumber = $item->{itemnumber}; >+ my $item = $builder->build_sample_item; >+ my $itemnumber = $item->itemnumber; > my $borrowernumber = $builder->build({ source => 'Borrower', value => { categorycode => $category->{categorycode}, branchcode => $branchcode }})->{borrowernumber}; > > my $resdate = dt_from_string->add( days => -20 ); >@@ -124,7 +122,7 @@ subtest 'Test handling of waiting reserves by CancelExpiredReserves' => sub { > my $hold1 = Koha::Hold->new({ > branchcode => $branchcode, > borrowernumber => $borrowernumber, >- biblionumber => $bibnum, >+ biblionumber => $item->biblionumber, > priority => 1, > reservedate => $resdate, > expirationdate => $notexpdate, >@@ -134,7 +132,7 @@ subtest 'Test handling of waiting reserves by CancelExpiredReserves' => sub { > my $hold2 = Koha::Hold->new({ > branchcode => $branchcode, > borrowernumber => $borrowernumber, >- biblionumber => $bibnum, >+ biblionumber => $item->biblionumber, > priority => 2, > reservedate => $resdate, > expirationdate => $expdate, >@@ -144,7 +142,7 @@ subtest 'Test handling of waiting reserves by CancelExpiredReserves' => sub { > my $hold3 = Koha::Hold->new({ > branchcode => $branchcode, > borrowernumber => $borrowernumber, >- biblionumber => $bibnum, >+ biblionumber => $item->biblionumber, > itemnumber => $itemnumber, > priority => 0, > reservedate => $resdate, >diff --git a/t/db_dependent/Reserves/GetReserveFee.t b/t/db_dependent/Reserves/GetReserveFee.t >index 4645c49901..cd9bdfac9e 100755 >--- a/t/db_dependent/Reserves/GetReserveFee.t >+++ b/t/db_dependent/Reserves/GetReserveFee.t >@@ -69,51 +69,44 @@ my $patron3 = $builder->build({ > }); > > # One biblio and two items >-my $biblio = $builder->build({ >- source => 'Biblio', >- value => { >- title => 'Title 1', >- }, >-}); >-my $item1 = $builder->build({ >- source => 'Item', >- value => { >- biblionumber => $biblio->{biblionumber}, >- notforloan => 0, >- }, >-}); >-my $item2 = $builder->build({ >- source => 'Item', >- value => { >- biblionumber => $biblio->{biblionumber}, >- notforloan => 0, >- }, >-}); >+my $biblio = $builder->build_sample_biblio; >+my $item1 = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ notforloan => 0, >+ } >+); >+my $item2 = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ notforloan => 0, >+ } >+); > > subtest 'GetReserveFee' => sub { > plan tests => 5; > >- C4::Circulation::AddIssue( $patron1, $item1->{barcode}, '2015-12-31', 0, undef, 0, {} ); # the date does not really matter >+ C4::Circulation::AddIssue( $patron1, $item1->barcode, '2015-12-31', 0, undef, 0, {} ); # the date does not really matter > my $acc2 = acctlines( $patron2->{borrowernumber} ); > my $res1 = addreserve( $patron1->{borrowernumber} ); > > t::lib::Mocks::mock_preference('HoldFeeMode', 'not_always'); >- my $fee = C4::Reserves::GetReserveFee( $patron2->{borrowernumber}, $biblio->{biblionumber} ); >+ my $fee = C4::Reserves::GetReserveFee( $patron2->{borrowernumber}, $biblio->biblionumber ); > is( $fee > 0, 1, 'Patron 2 should be charged cf GetReserveFee' ); >- C4::Reserves::ChargeReserveFee( $patron2->{borrowernumber}, $fee, $biblio->{title} ); >+ C4::Reserves::ChargeReserveFee( $patron2->{borrowernumber}, $fee, $biblio->title ); > is( acctlines( $patron2->{borrowernumber} ), $acc2 + 1, 'Patron 2 has been charged by ChargeReserveFee' ); > > # If we delete the reserve, there should be no charge > $dbh->do( "DELETE FROM reserves WHERE borrowernumber = ?", undef, ( $patron1->{borrowernumber}) ); >- $fee = C4::Reserves::GetReserveFee( $patron2->{borrowernumber}, $biblio->{biblionumber} ); >+ $fee = C4::Reserves::GetReserveFee( $patron2->{borrowernumber}, $biblio->biblionumber ); > is( $fee, 0, 'HoldFeeMode=not_always, Patron 2 should not be charged' ); > > t::lib::Mocks::mock_preference('HoldFeeMode', 'any_time_is_placed'); >- $fee = C4::Reserves::GetReserveFee( $patron2->{borrowernumber}, $biblio->{biblionumber} ); >+ $fee = C4::Reserves::GetReserveFee( $patron2->{borrowernumber}, $biblio->biblionumber ); > is( int($fee), 2, 'HoldFeeMode=any_time_is_placed, Patron 2 should be charged' ); > > t::lib::Mocks::mock_preference('HoldFeeMode', 'any_time_is_collected'); >- $fee = C4::Reserves::GetReserveFee( $patron2->{borrowernumber}, $biblio->{biblionumber} ); >+ $fee = C4::Reserves::GetReserveFee( $patron2->{borrowernumber}, $biblio->biblionumber ); > is( int($fee), 2, 'HoldFeeMode=any_time_is_collected, Patron 2 should be charged' ); > }; > >@@ -126,19 +119,19 @@ subtest 'Integration with AddReserve' => sub { > plan tests => 3; > > t::lib::Mocks::mock_preference('HoldFeeMode', 'not_always'); >- $dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->{biblionumber} ); >+ $dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); > $dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->{borrowernumber} ); > addreserve( $patron1->{borrowernumber} ); > is( acctlines( $patron1->{borrowernumber} ), 0, 'not_always - No fee charged for patron 1 if not issued' ); > > t::lib::Mocks::mock_preference('HoldFeeMode', 'any_time_is_placed'); >- $dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->{biblionumber} ); >+ $dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); > $dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->{borrowernumber} ); > addreserve( $patron1->{borrowernumber} ); > is( acctlines( $patron1->{borrowernumber} ), 1, 'any_time_is_placed - Patron should be always charged' ); > > t::lib::Mocks::mock_preference('HoldFeeMode', 'any_time_is_collected'); >- $dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->{biblionumber} ); >+ $dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); > $dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->{borrowernumber} ); > addreserve( $patron1->{borrowernumber} ); > is( acctlines( $patron1->{borrowernumber} ), 0, 'any_time_is_collected - Patron should not be charged when placing a hold' ); >@@ -147,23 +140,23 @@ subtest 'Integration with AddReserve' => sub { > subtest 'Items are issued' => sub { > plan tests => 3; > >- C4::Circulation::AddIssue( $patron2, $item1->{barcode}, '2015-12-31', 0, undef, 0, {} ); >+ C4::Circulation::AddIssue( $patron2, $item1->barcode, '2015-12-31', 0, undef, 0, {} ); > > t::lib::Mocks::mock_preference('HoldFeeMode', 'not_always'); >- $dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->{biblionumber} ); >+ $dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); > $dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->{borrowernumber} ); > addreserve( $patron1->{borrowernumber} ); > is( acctlines( $patron1->{borrowernumber} ), 0, 'not_always - Patron should not be charged if items are not all checked out' ); > >- $dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->{biblionumber} ); >+ $dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); > $dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->{borrowernumber} ); > addreserve( $patron3->{borrowernumber} ); > addreserve( $patron1->{borrowernumber} ); > # FIXME Are we sure it's the expected behavior? > is( acctlines( $patron1->{borrowernumber} ), 1, 'not_always - Patron should be charged if all the items are not checked out and at least 1 hold is already placed' ); > >- C4::Circulation::AddIssue( $patron3, $item2->{barcode}, '2015-12-31', 0, undef, 0, {} ); >- $dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->{biblionumber} ); >+ C4::Circulation::AddIssue( $patron3, $item2->barcode, '2015-12-31', 0, undef, 0, {} ); >+ $dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); > $dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->{borrowernumber} ); > addreserve( $patron1->{borrowernumber} ); > is( acctlines( $patron1->{borrowernumber} ), 1, 'not_always - Patron should be charged if all items are checked out' ); >@@ -174,27 +167,27 @@ subtest 'Integration with AddIssue' => sub { > plan tests => 5; > > $dbh->do( "DELETE FROM issues WHERE borrowernumber = ?", undef, $patron1->{borrowernumber} ); >- $dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->{biblionumber} ); >+ $dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); > $dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->{borrowernumber} ); > > t::lib::Mocks::mock_preference('HoldFeeMode', 'not_always'); >- C4::Circulation::AddIssue( $patron1, $item1->{barcode}, '2015-12-31', 0, undef, 0, {} ); >+ C4::Circulation::AddIssue( $patron1, $item1->barcode, '2015-12-31', 0, undef, 0, {} ); > is( acctlines( $patron1->{borrowernumber} ), 0, 'not_always - Patron should not be charged' ); > > t::lib::Mocks::mock_preference('HoldFeeMode', 'any_time_is_placed'); > $dbh->do( "DELETE FROM issues WHERE borrowernumber = ?", undef, $patron1->{borrowernumber} ); >- C4::Circulation::AddIssue( $patron1, $item1->{barcode}, '2015-12-31', 0, undef, 0, {} ); >+ C4::Circulation::AddIssue( $patron1, $item1->barcode, '2015-12-31', 0, undef, 0, {} ); > is( acctlines( $patron1->{borrowernumber} ), 0, 'not_always - Patron should not be charged' ); > > t::lib::Mocks::mock_preference('HoldFeeMode', 'any_time_is_collected'); > $dbh->do( "DELETE FROM issues WHERE borrowernumber = ?", undef, $patron1->{borrowernumber} ); >- C4::Circulation::AddIssue( $patron1, $item1->{barcode}, '2015-12-31', 0, undef, 0, {} ); >+ C4::Circulation::AddIssue( $patron1, $item1->barcode, '2015-12-31', 0, undef, 0, {} ); > is( acctlines( $patron1->{borrowernumber} ), 0, 'any_time_is_collected - Patron should not be charged when checking out an item which was not placed hold for him' ); > > $dbh->do( "DELETE FROM issues WHERE borrowernumber = ?", undef, $patron1->{borrowernumber} ); > my $id = addreserve( $patron1->{borrowernumber} ); > is( acctlines( $patron1->{borrowernumber} ), 0, 'any_time_is_collected - Patron should not be charged yet (just checking to make sure)'); >- C4::Circulation::AddIssue( $patron1, $item1->{barcode}, '2015-12-31', 0, undef, 0, {} ); >+ C4::Circulation::AddIssue( $patron1, $item1->barcode, '2015-12-31', 0, undef, 0, {} ); > is( acctlines( $patron1->{borrowernumber} ), 1, 'any_time_is_collected - Patron should not be charged when checking out an item which was not placed hold for him' ); > }; > >@@ -208,9 +201,9 @@ sub addreserve { > { > branchcode => $library->{branchcode}, > borrowernumber => $_[0], >- biblionumber => $biblio->{biblionumber}, >+ biblionumber => $biblio->biblionumber, > priority => '1', >- title => $biblio->{title}, >+ title => $biblio->title, > } > ); > } >diff --git a/t/db_dependent/Reserves/MultiplePerRecord.t b/t/db_dependent/Reserves/MultiplePerRecord.t >index 1a46a2f353..8d5cd68396 100755 >--- a/t/db_dependent/Reserves/MultiplePerRecord.t >+++ b/t/db_dependent/Reserves/MultiplePerRecord.t >@@ -64,54 +64,26 @@ my $itemtype2 = $builder->build( > } > ); > >-my $biblio = $builder->build( >+my $biblio = $builder->build_sample_biblio; >+my $item1 = $builder->build_sample_item( > { >- source => 'Biblio', >- value => { >- title => 'Title 1', >- }, >- } >-); >-my $biblioitem = $builder->build( >- { >- source => 'Biblioitem', >- value => { biblionumber => $biblio->{biblionumber} } >- } >+ biblionumber => $biblio->biblionumber, >+ itype => $itemtype1->{itemtype}, >+ library => $library->{branchcode}, >+ }, > ); >-my $item1 = $builder->build( >+my $item2 = $builder->build_sample_item( > { >- source => 'Item', >- value => { >- biblionumber => $biblio->{biblionumber}, >- itype => $itemtype1->{itemtype}, >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- damaged => 0, >- }, >+ biblionumber => $biblio->biblionumber, >+ itype => $itemtype2->{itemtype}, >+ library => $library->{branchcode}, > } > ); >-my $item2 = $builder->build( >+my $item3 = $builder->build_sample_item( > { >- source => 'Item', >- value => { >- biblionumber => $biblio->{biblionumber}, >- itype => $itemtype2->{itemtype}, >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- damaged => 0, >- }, >- } >-); >-my $item3 = $builder->build( >- { >- source => 'Item', >- value => { >- biblionumber => $biblio->{biblionumber}, >- itype => $itemtype2->{itemtype}, >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- damaged => 0, >- }, >+ biblionumber => $biblio->biblionumber, >+ itype => $itemtype2->{itemtype}, >+ library => $library->{branchcode}, > } > ); > >@@ -132,7 +104,7 @@ Koha::CirculationRules->set_rules( > > t::lib::Mocks::mock_preference('item-level_itypes', 1); # Assuming the item type is defined at item level > >-my $max = GetMaxPatronHoldsForRecord( $patron->{borrowernumber}, $biblio->{biblionumber} ); >+my $max = GetMaxPatronHoldsForRecord( $patron->{borrowernumber}, $biblio->biblionumber ); > is( $max, 1, 'GetMaxPatronHoldsForRecord returns max of 1' ); > my $rule = C4::Reserves::GetHoldRule( > $category->{categorycode}, >@@ -157,7 +129,7 @@ Koha::CirculationRules->set_rules( > } > ); > >-$max = GetMaxPatronHoldsForRecord( $patron->{borrowernumber}, $biblio->{biblionumber} ); >+$max = GetMaxPatronHoldsForRecord( $patron->{borrowernumber}, $biblio->biblionumber ); > is( $max, 2, 'GetMaxPatronHoldsForRecord returns max of 2' ); > $rule = C4::Reserves::GetHoldRule( > $category->{categorycode}, >@@ -182,7 +154,7 @@ Koha::CirculationRules->set_rules( > } > ); > >-$max = GetMaxPatronHoldsForRecord( $patron->{borrowernumber}, $biblio->{biblionumber} ); >+$max = GetMaxPatronHoldsForRecord( $patron->{borrowernumber}, $biblio->biblionumber ); > is( $max, 3, 'GetMaxPatronHoldsForRecord returns max of 3' ); > $rule = C4::Reserves::GetHoldRule( > $category->{categorycode}, >@@ -207,7 +179,7 @@ Koha::CirculationRules->set_rules( > } > ); > >-$max = GetMaxPatronHoldsForRecord( $patron->{borrowernumber}, $biblio->{biblionumber} ); >+$max = GetMaxPatronHoldsForRecord( $patron->{borrowernumber}, $biblio->biblionumber ); > is( $max, 4, 'GetMaxPatronHoldsForRecord returns max of 4' ); > $rule = C4::Reserves::GetHoldRule( > $category->{categorycode}, >@@ -232,7 +204,7 @@ Koha::CirculationRules->set_rules( > } > ); > >-$max = GetMaxPatronHoldsForRecord( $patron->{borrowernumber}, $biblio->{biblionumber} ); >+$max = GetMaxPatronHoldsForRecord( $patron->{borrowernumber}, $biblio->biblionumber ); > is( $max, 5, 'GetMaxPatronHoldsForRecord returns max of 1' ); > $rule = C4::Reserves::GetHoldRule( > $category->{categorycode}, >@@ -254,7 +226,7 @@ is( $holds->forced_hold_level, undef, "No holds does not force an item or record > my $hold = Koha::Hold->new({ > borrowernumber => $patron->{borrowernumber}, > reservedate => '1981-06-10', >- biblionumber => $biblio->{biblionumber}, >+ biblionumber => $biblio->biblionumber, > branchcode => $library->{branchcode}, > priority => 1, > })->store(); >@@ -262,7 +234,7 @@ my $hold = Koha::Hold->new({ > $holds = Koha::Holds->search( { borrowernumber => $patron->{borrowernumber} } ); > is( $holds->forced_hold_level, 'record', "Record level hold forces record level holds" ); > >-$hold->itemnumber( $item1->{itemnumber} ); >+$hold->itemnumber( $item1->itemnumber ); > $hold->store(); > > $holds = Koha::Holds->search( { borrowernumber => $patron->{borrowernumber} } ); >@@ -283,38 +255,38 @@ Koha::CirculationRules->set_rules( > } > ); > >-my $can = CanBookBeReserved($patron->{borrowernumber}, $biblio->{biblionumber}); >+my $can = CanBookBeReserved($patron->{borrowernumber}, $biblio->biblionumber); > is( $can->{status}, 'OK', 'Hold can be placed with 0 holds' ); > my $hold_id = AddReserve( > { > branchcode => $library->{branchcode}, > borrowernumber => $patron->{borrowernumber}, >- biblionumber => $biblio->{biblionumber}, >+ biblionumber => $biblio->biblionumber, > priority => 1 > } > ); > ok( $hold_id, 'First hold was placed' ); > >-$can = CanBookBeReserved($patron->{borrowernumber}, $biblio->{biblionumber}); >+$can = CanBookBeReserved($patron->{borrowernumber}, $biblio->biblionumber); > is( $can->{status}, 'OK', 'Hold can be placed with 1 hold' ); > $hold_id = AddReserve( > { > branchcode => $library->{branchcode}, > borrowernumber => $patron->{borrowernumber}, >- biblionumber => $biblio->{biblionumber}, >+ biblionumber => $biblio->biblionumber, > priority => 1 > } > ); > ok( $hold_id, 'Second hold was placed' ); > >-$can = CanBookBeReserved($patron->{borrowernumber}, $biblio->{biblionumber}); >+$can = CanBookBeReserved($patron->{borrowernumber}, $biblio->biblionumber); > is( $can->{status}, 'tooManyHoldsForThisRecord', 'Third hold exceeds limit of holds per record' ); > > Koha::Holds->find($hold_id)->found("W")->store; >-$can = CanBookBeReserved($patron->{borrowernumber}, $biblio->{biblionumber}); >+$can = CanBookBeReserved($patron->{borrowernumber}, $biblio->biblionumber); > is( $can->{status}, 'tooManyHoldsForThisRecord', 'Third hold exceeds limit of holds per record' ); > >-$can = CanBookBeReserved($patron->{borrowernumber}, $biblio->{biblionumber}, undef, { ignore_found_holds => 1 }); >+$can = CanBookBeReserved($patron->{borrowernumber}, $biblio->biblionumber, undef, { ignore_found_holds => 1 }); > is( $can->{status}, 'OK', 'Third hold is allowed when ignoring waiting holds' ); > > $schema->storage->txn_rollback; >diff --git a/t/db_dependent/Reserves/ReserveSlip.t b/t/db_dependent/Reserves/ReserveSlip.t >index cd7a1936b4..03b5731644 100644 >--- a/t/db_dependent/Reserves/ReserveSlip.t >+++ b/t/db_dependent/Reserves/ReserveSlip.t >@@ -50,41 +50,24 @@ my $patron = $builder->build( > ); > > >-my $biblio = $builder->build( >+my $biblio = $builder->build_sample_biblio; >+my $item1 = $builder->build_sample_item( > { >- source => 'Biblio', >- value => { >- title => 'Title 1', >- }, >+ biblionumber => $biblio->biblionumber, >+ library => $library->{branchcode}, > } > ); >- >-my $item1 = $builder->build( >+my $item2 = $builder->build_sample_item( > { >- source => 'Item', >- value => { >- biblionumber => $biblio->{biblionumber}, >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- }, >- } >-); >- >-my $item2 = $builder->build( >- { >- source => 'Item', >- value => { >- biblionumber => $biblio->{biblionumber}, >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- }, >+ biblionumber => $biblio->biblionumber, >+ library => $library->{branchcode}, > } > ); > > my $hold1 = Koha::Hold->new( > { >- biblionumber => $biblio->{biblionumber}, >- itemnumber => $item1->{itemnumber}, >+ biblionumber => $biblio->biblionumber, >+ itemnumber => $item1->itemnumber, > waitingdate => '2000-01-01', > borrowernumber => $patron->{borrowernumber}, > branchcode => $library->{branchcode}, >@@ -93,8 +76,8 @@ my $hold1 = Koha::Hold->new( > > my $hold2 = Koha::Hold->new( > { >- biblionumber => $biblio->{biblionumber}, >- itemnumber => $item2->{itemnumber}, >+ biblionumber => $biblio->biblionumber, >+ itemnumber => $item2->itemnumber, > waitingdate => '2000-01-01', > borrowernumber => $patron->{borrowernumber}, > branchcode => $library->{branchcode}, >@@ -126,7 +109,7 @@ is (ReserveSlip({ > branchcode => $library->{branchcode}, > reserve_id => $hold1->reserve_id, > })->{content}, >- "Hold found for $patron->{firstname}: Please pick up $biblio->{title} with barcode $item1->{barcode} at $library->{branchcode}.", "Hold slip contains correctly parsed content"); >+ sprintf( "Hold found for %s: Please pick up %s with barcode %s at %s.", $patron->{firstname}, $biblio->title, $item1->barcode, $library->{branchcode}),"Hold slip contains correctly parsed content"); > > $schema->storage->txn_rollback; > >diff --git a/t/db_dependent/SIP/Message.t b/t/db_dependent/SIP/Message.t >index 3b6eed812d..b4ebc9c116 100755 >--- a/t/db_dependent/SIP/Message.t >+++ b/t/db_dependent/SIP/Message.t >@@ -176,14 +176,14 @@ subtest "Test build_additional_item_fields_string" => sub { > > my $builder = t::lib::TestBuilder->new(); > >- my $item = $builder->build( { source => 'Item' } ); >- my $ils_item = C4::SIP::ILS::Item->new( $item->{barcode} ); >+ my $item = $builder->build_sample_item; >+ my $ils_item = C4::SIP::ILS::Item->new( $item->barcode ); > > my $server = {}; > $server->{account}->{item_field}->{code} = 'itemnumber'; > $server->{account}->{item_field}->{field} = 'XY'; > my $attribute_string = $ils_item->build_additional_item_fields_string( $server ); >- is( $attribute_string, "XY$item->{itemnumber}|", 'Attribute field generated correctly with single param' ); >+ is( $attribute_string, "XY".$item->itemnumber."|", 'Attribute field generated correctly with single param' ); > > $server = {}; > $server->{account}->{item_field}->[0]->{code} = 'itemnumber'; >@@ -191,7 +191,7 @@ subtest "Test build_additional_item_fields_string" => sub { > $server->{account}->{item_field}->[1]->{code} = 'biblionumber'; > $server->{account}->{item_field}->[1]->{field} = 'YZ'; > $attribute_string = $ils_item->build_additional_item_fields_string( $server ); >- is( $attribute_string, "XY$item->{itemnumber}|YZ$item->{biblionumber}|", 'Attribute field generated correctly with multiple params' ); >+ is( $attribute_string, sprintf("XY%s|YZ%s|", $item->itemnumber, $item->biblionumber), 'Attribute field generated correctly with multiple params' ); > > $schema->storage->txn_rollback; > }; >@@ -550,14 +550,14 @@ sub test_hold_patron_bcode { > my ( $response, $findpatron ); > my $mocks = create_mocks( \$response, \$findpatron, \$branchcode ); > >- my $item = $builder->build({ >- source => 'Item', >- value => { damaged => 0, withdrawn => 0, itemlost => 0, restricted => 0, homebranch => $branchcode, holdingbranch => $branchcode }, >- }); >- my $item_object = Koha::Items->find( $item->{itemnumber} ); >+ my $item = $builder->build_sample_item( >+ { >+ library => $branchcode >+ } >+ ); > > my $server = { ils => $mocks->{ils} }; >- my $sip_item = C4::SIP::ILS::Item->new( $item->{barcode} ); >+ my $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); > > is( $sip_item->hold_patron_bcode, q{}, "SIP item with no hold returns empty string" ); > >diff --git a/t/db_dependent/StockRotationRotas.t b/t/db_dependent/StockRotationRotas.t >index 31e63c4868..9d5401f140 100644 >--- a/t/db_dependent/StockRotationRotas.t >+++ b/t/db_dependent/StockRotationRotas.t >@@ -66,12 +66,12 @@ subtest 'Basic object tests' => sub { > > #### Test add_item > >- my $item = $builder->build({ source => 'Item' }); >+ my $item = $builder->build_sample_item; > >- $srrota->add_item($item->{itemnumber}); >+ $srrota->add_item($item->itemnumber); > > is( >- Koha::StockRotationItems->find($item->{itemnumber})->stage_id, >+ Koha::StockRotationItems->find($item->itemnumber)->stage_id, > $srrota->first_stage->stage_id, > "Adding an item results in a new sritem item being assigned to the first stage." > ); >@@ -85,10 +85,10 @@ subtest 'Basic object tests' => sub { > value => { rota_id => $newrota->{rota_id} }, > }); > >- $srnewrota->add_item($item->{itemnumber}); >+ $srnewrota->add_item($item->itemnumber); > > is( >- Koha::StockRotationItems->find($item->{itemnumber})->stage_id, >+ Koha::StockRotationItems->find($item->itemnumber)->stage_id, > $srnewrota->stockrotationstages->next->stage_id, > "Moving an item results in that sritem being assigned to the new first stage." > ); >diff --git a/t/db_dependent/Virtualshelves.t b/t/db_dependent/Virtualshelves.t >index fb14573e37..d349b7b39b 100644 >--- a/t/db_dependent/Virtualshelves.t >+++ b/t/db_dependent/Virtualshelves.t >@@ -174,10 +174,10 @@ subtest 'Shelf content' => sub { > plan tests => 18; > my $patron1 = $builder->build( { source => 'Borrower', } ); > my $patron2 = $builder->build( { source => 'Borrower', } ); >- my $biblio1 = $builder->build( { source => 'Biblio', } ); >- my $biblio2 = $builder->build( { source => 'Biblio', } ); >- my $biblio3 = $builder->build( { source => 'Biblio', } ); >- my $biblio4 = $builder->build( { source => 'Biblio', } ); >+ my $biblio1 = $builder->build_sample_biblio; >+ my $biblio2 = $builder->build_sample_biblio; >+ my $biblio3 = $builder->build_sample_biblio; >+ my $biblio4 = $builder->build_sample_biblio; > my $number_of_contents = Koha::Virtualshelfcontents->search->count; > > is( $number_of_contents, 0, 'No content should exist' ); >@@ -193,15 +193,15 @@ subtest 'Shelf content' => sub { > > $shelf = Koha::Virtualshelves->find( $shelf->shelfnumber ); > is( t::lib::Dates::compare( $shelf->lastmodified, $dt_yesterday), 0, 'The lastmodified has been set to yesterday, will be useful for another test later' ); >- my $content1 = $shelf->add_biblio( $biblio1->{biblionumber}, $patron1->{borrowernumber} ); >+ my $content1 = $shelf->add_biblio( $biblio1->biblionumber, $patron1->{borrowernumber} ); > is( ref($content1), 'Koha::Virtualshelfcontent', 'add_biblio to a shelf should return a Koha::Virtualshelfcontent object if inserted' ); > $shelf = Koha::Virtualshelves->find( $shelf->shelfnumber ); > is( t::lib::Dates::compare( $shelf->lastmodified, dt_from_string), 0, 'Adding a biblio to a shelf should update the lastmodified for the shelf' ); >- my $content2 = $shelf->add_biblio( $biblio2->{biblionumber}, $patron1->{borrowernumber} ); >+ my $content2 = $shelf->add_biblio( $biblio2->biblionumber, $patron1->{borrowernumber} ); > $number_of_contents = Koha::Virtualshelfcontents->search->count; > is( $number_of_contents, 2, '2 biblio should have been inserted' ); > >- my $content1_bis = $shelf->add_biblio( $biblio1->{biblionumber}, $patron1->{borrowernumber} ); >+ my $content1_bis = $shelf->add_biblio( $biblio1->biblionumber, $patron1->{borrowernumber} ); > is( $content1_bis, undef, 'add_biblio should return undef on duplicate' ); # Or an exception ? > $number_of_contents = Koha::Virtualshelfcontents->search->count; > is( $number_of_contents, 2, 'The biblio should not have been duplicated' ); >@@ -212,10 +212,10 @@ subtest 'Shelf content' => sub { > > # Patron 2 will try to remove biblios > # allow_change_from_owner = 1, allow_change_from_others = 0 (defaults) >- my $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio1->{biblionumber} ], borrowernumber => $patron2->{borrowernumber} } ); >+ my $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio1->biblionumber ], borrowernumber => $patron2->{borrowernumber} } ); > is( $number_of_deleted_biblios, 0, 'Patron 2 removed nothing' ); > # Now try with patron 1 >- $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio1->{biblionumber} ], borrowernumber => $patron1->{borrowernumber} } ); >+ $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio1->biblionumber ], borrowernumber => $patron1->{borrowernumber} } ); > is( $number_of_deleted_biblios, 1, 'Patron 1 removed biblio' ); > $number_of_contents = Koha::Virtualshelfcontents->search->count; > is( $number_of_contents, 1, 'To be sure the content has been deleted' ); >@@ -223,26 +223,26 @@ subtest 'Shelf content' => sub { > # allow_change_from_owner == 0 (readonly) > $shelf->allow_change_from_owner( 0 ); > $shelf->store; >- $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio2->{biblionumber} ], borrowernumber => $patron1->{borrowernumber} } ); >+ $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio2->biblionumber ], borrowernumber => $patron1->{borrowernumber} } ); > is( $number_of_deleted_biblios, 0, 'Owner could not delete' ); > $number_of_contents = Koha::Virtualshelfcontents->search->count; > is( $number_of_contents, 1, 'Number of entries still equal to 1' ); >- $shelf->add_biblio( $biblio2->{biblionumber}, $patron1->{borrowernumber} ); >+ $shelf->add_biblio( $biblio2->biblionumber, $patron1->{borrowernumber} ); > $number_of_contents = Koha::Virtualshelfcontents->search->count; > is( $number_of_contents, 1, 'Biblio not added to the list' ); > # Add back biblio1 > $shelf->allow_change_from_owner( 1 ); >- $shelf->add_biblio( $biblio1->{biblionumber}, $patron1->{borrowernumber} ); >+ $shelf->add_biblio( $biblio1->biblionumber, $patron1->{borrowernumber} ); > $number_of_contents = Koha::Virtualshelfcontents->search->count; > is( $number_of_contents, 2, 'Biblio added to the list' ); > > # allow_change_from_others == 1 > $shelf->allow_change_from_others( 1 ); >- my $content3 = $shelf->add_biblio( $biblio3->{biblionumber}, $patron2->{borrowernumber} ); >- my $content4 = $shelf->add_biblio( $biblio4->{biblionumber}, $patron2->{borrowernumber} ); >+ my $content3 = $shelf->add_biblio( $biblio3->biblionumber, $patron2->{borrowernumber} ); >+ my $content4 = $shelf->add_biblio( $biblio4->biblionumber, $patron2->{borrowernumber} ); > $number_of_contents = Koha::Virtualshelfcontents->search->count; > is( $number_of_contents, 4, 'The biblio should have been added to the shelf by the patron 2' ); >- $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio3->{biblionumber} ], borrowernumber => $patron2->{borrowernumber} } ); >+ $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio3->biblionumber ], borrowernumber => $patron2->{borrowernumber} } ); > is( $number_of_deleted_biblios, 1, 'Biblio 3 deleted by patron 2' ); > $number_of_contents = Koha::Virtualshelfcontents->search->count; > is( $number_of_contents, 3, 'Back to three entries' ); >@@ -255,11 +255,10 @@ subtest 'Shelf permissions' => sub { > plan tests => 40; > my $patron1 = $builder->build( { source => 'Borrower', value => { flags => '2096766' } } ); # 2096766 is everything checked but not superlibrarian > my $patron2 = $builder->build( { source => 'Borrower', value => { flags => '1048190' } } ); # 1048190 is everything checked but not superlibrarian and delete_public_lists >- my $biblio1 = $builder->build( { source => 'Biblio', } ); >- my $biblio2 = $builder->build( { source => 'Biblio', } ); >- my $biblio3 = $builder->build( { source => 'Biblio', } ); >- my $biblio4 = $builder->build( { source => 'Biblio', } ); >- >+ my $biblio1 = $builder->build_sample_biblio; >+ my $biblio2 = $builder->build_sample_biblio; >+ my $biblio3 = $builder->build_sample_biblio; >+ my $biblio4 = $builder->build_sample_biblio; > > my $public_shelf = Koha::Virtualshelf->new( > { shelfname => "my first shelf", >@@ -412,10 +411,10 @@ subtest 'Get shelves containing biblios' => sub { > plan tests => 9; > my $patron1 = $builder->build( { source => 'Borrower', } ); > my $patron2 = $builder->build( { source => 'Borrower', } ); >- my $biblio1 = $builder->build( { source => 'Biblio', } ); >- my $biblio2 = $builder->build( { source => 'Biblio', } ); >- my $biblio3 = $builder->build( { source => 'Biblio', } ); >- my $biblio4 = $builder->build( { source => 'Biblio', } ); >+ my $biblio1 = $builder->build_sample_biblio; >+ my $biblio2 = $builder->build_sample_biblio; >+ my $biblio3 = $builder->build_sample_biblio; >+ my $biblio4 = $builder->build_sample_biblio; > > my $shelf1 = Koha::Virtualshelf->new( > { shelfname => "my first shelf", >@@ -436,23 +435,23 @@ subtest 'Get shelves containing biblios' => sub { > } > )->store; > >- my $content1 = $shelf1->add_biblio( $biblio1->{biblionumber}, $patron1->{borrowernumber} ); >- my $content2 = $shelf1->add_biblio( $biblio2->{biblionumber}, $patron1->{borrowernumber} ); >- my $content3 = $shelf2->add_biblio( $biblio2->{biblionumber}, $patron2->{borrowernumber} ); >- my $content4 = $shelf2->add_biblio( $biblio3->{biblionumber}, $patron2->{borrowernumber} ); >- my $content5 = $shelf2->add_biblio( $biblio4->{biblionumber}, $patron2->{borrowernumber} ); >- my $content6 = $shelf3->add_biblio( $biblio4->{biblionumber}, $patron1->{borrowernumber} ); >+ my $content1 = $shelf1->add_biblio( $biblio1->biblionumber, $patron1->{borrowernumber} ); >+ my $content2 = $shelf1->add_biblio( $biblio2->biblionumber, $patron1->{borrowernumber} ); >+ my $content3 = $shelf2->add_biblio( $biblio2->biblionumber, $patron2->{borrowernumber} ); >+ my $content4 = $shelf2->add_biblio( $biblio3->biblionumber, $patron2->{borrowernumber} ); >+ my $content5 = $shelf2->add_biblio( $biblio4->biblionumber, $patron2->{borrowernumber} ); >+ my $content6 = $shelf3->add_biblio( $biblio4->biblionumber, $patron1->{borrowernumber} ); > > my $shelves_with_biblio1_for_any_patrons = Koha::Virtualshelves->get_shelves_containing_record( > { >- biblionumber => $biblio1->{biblionumber}, >+ biblionumber => $biblio1->biblionumber, > } > ); > is ( $shelves_with_biblio1_for_any_patrons->count, 0, 'shelf1 is private and should not be displayed if patron is not logged in' ); > > my $shelves_with_biblio4_for_any_patrons = Koha::Virtualshelves->get_shelves_containing_record( > { >- biblionumber => $biblio4->{biblionumber}, >+ biblionumber => $biblio4->biblionumber, > } > ); > is ( $shelves_with_biblio4_for_any_patrons->count, 1, 'shelf3 is public and should be displayed for any patrons' ); >@@ -460,7 +459,7 @@ subtest 'Get shelves containing biblios' => sub { > > my $shelves_with_biblio1_for_other_patrons = Koha::Virtualshelves->get_shelves_containing_record( > { >- biblionumber => $biblio1->{biblionumber}, >+ biblionumber => $biblio1->biblionumber, > borrowernumber => $patron2->{borrowernumber}, > } > ); >@@ -468,7 +467,7 @@ subtest 'Get shelves containing biblios' => sub { > > my $shelves_with_biblio1_for_owner = Koha::Virtualshelves->get_shelves_containing_record( > { >- biblionumber => $biblio1->{biblionumber}, >+ biblionumber => $biblio1->biblionumber, > borrowernumber => $patron1->{borrowernumber}, > } > ); >@@ -476,7 +475,7 @@ subtest 'Get shelves containing biblios' => sub { > > my $shelves_with_biblio2_for_patron1 = Koha::Virtualshelves->get_shelves_containing_record( > { >- biblionumber => $biblio2->{biblionumber}, >+ biblionumber => $biblio2->biblionumber, > borrowernumber => $patron1->{borrowernumber}, > } > ); >@@ -485,7 +484,7 @@ subtest 'Get shelves containing biblios' => sub { > > my $shelves_with_biblio4_for_patron2 = Koha::Virtualshelves->get_shelves_containing_record( > { >- biblionumber => $biblio4->{biblionumber}, >+ biblionumber => $biblio4->biblionumber, > borrowernumber => $patron2->{borrowernumber}, > } > ); >diff --git a/t/db_dependent/api/v1/items.t b/t/db_dependent/api/v1/items.t >index a4c62aa0a2..a3ba781cf4 100644 >--- a/t/db_dependent/api/v1/items.t >+++ b/t/db_dependent/api/v1/items.t >@@ -43,7 +43,7 @@ subtest 'list() tests' => sub { > > $schema->storage->txn_begin; > >- my $item = $builder->build_object( { class => 'Koha::Items' } ); >+ my $item = $builder->build_sample_item; > my $patron = $builder->build_object( > { > class => 'Koha::Patrons', >@@ -53,7 +53,7 @@ subtest 'list() tests' => sub { > > # Make sure we have at least 10 items > for ( 1..10 ) { >- $builder->build_object({ class => 'Koha::Items' }); >+ $builder->build_sample_item; > } > > my $nonprivilegedpatron = $builder->build_object( >@@ -105,7 +105,7 @@ subtest 'get() tests' => sub { > > $schema->storage->txn_begin; > >- my $item = $builder->build_object( { class => 'Koha::Items' } ); >+ my $item = $builder->build_sample_item; > my $patron = $builder->build_object({ > class => 'Koha::Patrons', > value => { flags => 4 } >diff --git a/t/db_dependent/cronjobs/advance_notices_digest.t b/t/db_dependent/cronjobs/advance_notices_digest.t >index 96024f6997..3fa10ec8df 100644 >--- a/t/db_dependent/cronjobs/advance_notices_digest.t >+++ b/t/db_dependent/cronjobs/advance_notices_digest.t >@@ -117,24 +117,9 @@ DELETESQL > } > }); > >- my $biblio = $builder->build({ >- source => 'Biblio', >- }); >- my $biblioitem = $builder->build({ >- source => 'Biblioitem', >- value => { >- biblionumber => $biblio->{biblionumber} >- } >- }); >- my $item1 = $builder->build({ >- source => 'Item' >- }); >- my $item2 = $builder->build({ >- source => 'Item' >- }); >- my $item3 = $builder->build({ >- source => 'Item' >- }); >+ my $item1 = $builder->build_sample_item; >+ my $item2 = $builder->build_sample_item; >+ my $item3 = $builder->build_sample_item; > my $now = dt_from_string(); > my $tomorrow = $now->add(days => 1)->strftime('%F'); > >@@ -142,7 +127,7 @@ DELETESQL > source => 'Issue', > value => { > date_due => $tomorrow, >- itemnumber => $item1->{itemnumber}, >+ itemnumber => $item1->itemnumber, > branchcode => $library2->{branchcode}, > borrowernumber => $borrower->{borrowernumber}, > returndate => undef >@@ -153,7 +138,7 @@ DELETESQL > source => 'Issue', > value => { > date_due => $tomorrow, >- itemnumber => $item2->{itemnumber}, >+ itemnumber => $item2->itemnumber, > branchcode => $library3->{branchcode}, > borrowernumber => $borrower->{borrowernumber}, > returndate => undef >@@ -163,7 +148,7 @@ DELETESQL > source => 'Issue', > value => { > date_due => $tomorrow, >- itemnumber => $item3->{itemnumber}, >+ itemnumber => $item3->itemnumber, > branchcode => $library3->{branchcode}, > borrowernumber => $borrower->{borrowernumber}, > returndate => undef >diff --git a/t/db_dependent/rollingloans.t b/t/db_dependent/rollingloans.t >index 973ab98c9d..605bde4f38 100644 >--- a/t/db_dependent/rollingloans.t >+++ b/t/db_dependent/rollingloans.t >@@ -29,27 +29,21 @@ my $test_item_24 = '502326000404'; > my $test_item_48 = '502326000403'; > > my $borrower1 = $builder->build_object({ class => 'Koha::Patrons', value => { cardnumber => $test_patron } }); >-my $item1 = $builder->build_object({ >- class => 'Koha::Items', >- value => { >+my $item1 = $builder->build_sample_item( >+ { > barcode => $test_item_fic, >- biblionumber => $builder->build( { source => 'Biblioitem' } )->{biblionumber}, > } >-}); >-my $item2 = $builder->build_object({ >- class => 'Koha::Items', >- value => { >+); >+my $item2 = $builder->build_sample_item( >+ { > barcode => $test_item_24, >- biblionumber => $builder->build( { source => 'Biblioitem' } )->{biblionumber}, > } >-}); >-my $item3 = $builder->build_object({ >- class => 'Koha::Items', >- value => { >+); >+my $item3 = $builder->build_sample_item( >+ { > barcode => $test_item_48, >- biblionumber => $builder->build( { source => 'Biblioitem' } )->{biblionumber}, > } >-}); >+); > > SKIP: { > skip 'Missing test borrower or item, skipping tests', 8 >diff --git a/t/db_dependent/selenium/regressions.t b/t/db_dependent/selenium/regressions.t >index ed2a68cdd4..a2cd6bc061 100644 >--- a/t/db_dependent/selenium/regressions.t >+++ b/t/db_dependent/selenium/regressions.t >@@ -139,17 +139,10 @@ subtest 'Display circulation table correctly' => sub { > ); > > my ( $biblionumber, $biblioitemnumber ) = add_biblio(); >- my $item = $builder->build_object( >+ my $item = $builder->build_sample_item( > { >- class => 'Koha::Items', >- value => { >- biblionumber => $biblionumber, >- homebranch => $library->branchcode, >- holdingbranch => $library->branchcode, >- notforloan => 0, >- itemlost => 0, >- withdrawn => 0, >- } >+ biblionumber => $biblionumber, >+ library => $library->branchcode, > } > ); > my $context = Test::MockModule->new('C4::Context'); >-- >2.11.0
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 26250
:
108590
|
108591
|
108623
|
108627
|
108730
|
108731
|
109208
|
109209
|
109838