Bugzilla – Attachment 93259 Details for
Bug 21985
Test t/db_dependent/Circulation.t fails if SearchEngine is set to elasticsearch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21985: Fix Circulation tests when ES it set, by using build_sample_item
Bug-21985-Fix-Circulation-tests-when-ES-it-set-by-.patch (text/plain), 16.63 KB, created by
Nick Clemens (kidclamp)
on 2019-09-30 13:55:10 UTC
(
hide
)
Description:
Bug 21985: Fix Circulation tests when ES it set, by using build_sample_item
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2019-09-30 13:55:10 UTC
Size:
16.63 KB
patch
obsolete
>From 852c11665d96577fc72606e59b0eb0c51bd36c2b Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Sun, 16 Dec 2018 12:28:48 -0300 >Subject: [PATCH] Bug 21985: Fix Circulation tests when ES it set, by using > build_sample_item > >We should use build_sample item (from bug 21971) to create items, >otherwise we may not have a valid biblioitem and/or MARC record. > >Test plan: >Set SearchEngine to ES >prove that the tests in Circulation.t now pass > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > t/db_dependent/Circulation.t | 273 +++++++++++++------------------------------ > t/lib/TestBuilder.pm | 1 + > 2 files changed, 83 insertions(+), 191 deletions(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 4399abe75c..fa3568bf56 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -1296,16 +1296,12 @@ subtest 'CanBookBeIssued & AllowReturnToBranch' => sub { > my $patron_1 = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } ); > my $patron_2 = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } ); > >- my $biblioitem = $builder->build( { source => 'Biblioitem' } ); >- my $item = $builder->build( >- { source => 'Item', >- value => { >- homebranch => $homebranch->{branchcode}, >- holdingbranch => $holdingbranch->{branchcode}, >- biblionumber => $biblioitem->{biblionumber} >- } >+ my $item = $builder->build_sample_item( >+ { >+ homebranch => $homebranch->{branchcode}, >+ holdingbranch => $holdingbranch->{branchcode}, > } >- ); >+ )->unblessed; > > set_userenv($holdingbranch); > >@@ -1387,19 +1383,12 @@ subtest 'AddIssue & AllowReturnToBranch' => sub { > my $patron_1 = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); > my $patron_2 = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); > >- my $biblioitem = $builder->build( { source => 'Biblioitem' } ); >- my $item = $builder->build( >- { source => 'Item', >- value => { >- homebranch => $homebranch->{branchcode}, >- holdingbranch => $holdingbranch->{branchcode}, >- notforloan => 0, >- itemlost => 0, >- withdrawn => 0, >- biblionumber => $biblioitem->{biblionumber} >- } >+ my $item = $builder->build_sample_item( >+ { >+ homebranch => $homebranch->{branchcode}, >+ holdingbranch => $holdingbranch->{branchcode}, > } >- ); >+ )->unblessed; > > set_userenv($holdingbranch); > >@@ -1456,27 +1445,16 @@ subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { > > my $library = $builder->build( { source => 'Branch' } ); > my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } ); >- >- my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } ); >- my $item_1 = $builder->build( >- { source => 'Item', >- value => { >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- biblionumber => $biblioitem_1->{biblionumber} >- } >+ my $item_1 = $builder->build_sample_item( >+ { >+ library => $library->{branchcode}, > } >- ); >- my $biblioitem_2 = $builder->build( { source => 'Biblioitem' } ); >- my $item_2 = $builder->build( >- { source => 'Item', >- value => { >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- biblionumber => $biblioitem_2->{biblionumber} >- } >+ )->unblessed; >+ my $item_2 = $builder->build_sample_item( >+ { >+ library => $library->{branchcode}, > } >- ); >+ )->unblessed; > > my ( $error, $question, $alerts ); > >@@ -1529,17 +1507,11 @@ subtest 'CanBookBeIssued + Statistic patrons "X"' => sub { > } > } > ); >- my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } ); >- my $item_1 = $builder->build( >+ my $item_1 = $builder->build_sample_item( > { >- source => 'Item', >- value => { >- homebranch => $library->branchcode, >- holdingbranch => $library->branchcode, >- biblionumber => $biblioitem_1->{biblionumber} >- } >+ library => $library->{branchcode}, > } >- ); >+ )->unblessed; > > 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)' ); >@@ -1645,26 +1617,24 @@ subtest 'CanBookBeIssued + AllowMultipleIssuesOnABiblio' => sub { > my $library = $builder->build( { source => 'Branch' } ); > my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } ); > >- my $biblioitem = $builder->build( { source => 'Biblioitem' } ); >- my $biblionumber = $biblioitem->{biblionumber}; >- my $item_1 = $builder->build( >- { source => 'Item', >- value => { >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- biblionumber => $biblionumber, >- } >+ my $biblionumber = $builder->build_sample_biblio( >+ { >+ branchcode => $library->{branchcode}, > } >- ); >- my $item_2 = $builder->build( >- { source => 'Item', >- value => { >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- biblionumber => $biblionumber, >- } >+ )->biblionumber; >+ my $item_1 = $builder->build_sample_item( >+ { >+ 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 ) ); >@@ -1697,34 +1667,23 @@ subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { > my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); > > # Add 2 items >- my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } ); >- my $item_1 = $builder->build( >+ my $biblionumber = $builder->build_sample_biblio( > { >- source => 'Item', >- value => { >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- notforloan => 0, >- itemlost => 0, >- withdrawn => 0, >- biblionumber => $biblioitem_1->{biblionumber} >- } >+ branchcode => $library->{branchcode}, > } >- ); >- my $biblioitem_2 = $builder->build( { source => 'Biblioitem' } ); >- my $item_2 = $builder->build( >+ )->biblionumber; >+ my $item_1 = $builder->build_sample_item( > { >- source => 'Item', >- value => { >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- notforloan => 0, >- itemlost => 0, >- withdrawn => 0, >- biblionumber => $biblioitem_2->{biblionumber} >- } >+ biblionumber => $biblionumber, >+ library => $library->{branchcode}, > } >- ); >+ )->unblessed; >+ my $item_2 = $builder->build_sample_item( >+ { >+ biblionumber => $biblionumber, >+ library => $library->{branchcode}, >+ } >+ )->unblessed; > > # And the issuing rule > Koha::IssuingRules->search->delete; >@@ -1818,21 +1777,17 @@ subtest 'AddReturn + suspension_chargeperiod' => sub { > my $library = $builder->build( { source => 'Branch' } ); > my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } ); > >- # Add 2 items >- my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } ); >- my $item_1 = $builder->build( >+ my $biblionumber = $builder->build_sample_biblio( > { >- source => 'Item', >- value => { >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- notforloan => 0, >- itemlost => 0, >- withdrawn => 0, >- biblionumber => $biblioitem_1->{biblionumber} >- } >+ branchcode => $library->{branchcode}, > } >- ); >+ )->biblionumber; >+ my $item_1 = $builder->build_sample_item( >+ { >+ biblionumber => $biblionumber, >+ library => $library->{branchcode}, >+ } >+ )->unblessed; > > # And the issuing rule > Koha::IssuingRules->search->delete; >@@ -2045,33 +2000,11 @@ subtest 'AddReturn | is_overdue' => sub { > my $manager = $builder->build_object({ class => "Koha::Patrons" }); > t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $manager->branchcode }); > >- my $biblioitem = $builder->build( { source => 'Biblioitem' } ); >- my $item_type = $builder->build_object( >- { class => 'Koha::ItemTypes', >- value => { >- notforloan => undef, >- rentalcharge => 0, >- defaultreplacecost => undef, >- processfee => 0, >- rentalcharge_daily => 0, >- } >- } >- ); >- my $item = $builder->build( >+ my $item = $builder->build_sample_item( > { >- source => 'Item', >- value => { >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- notforloan => 0, >- itemlost => 0, >- withdrawn => 0, >- biblionumber => $biblioitem->{biblionumber}, >- replacementprice => 7, >- itype => $item_type->itemtype >- } >+ library => $library->{branchcode}, > } >- ); >+ )->unblessed; > > Koha::IssuingRules->search->delete; > my $rule = Koha::IssuingRule->new( >@@ -2658,26 +2591,15 @@ subtest 'Set waiting flag' => sub { > my $library_2 = $builder->build( { source => 'Branch' } ); > my $patron_2 = $builder->build( { source => 'Borrower', value => { branchcode => $library_2->{branchcode}, categorycode => $patron_category->{categorycode} } } ); > >- my $biblio = $builder->build( { source => 'Biblio' } ); >- my $biblioitem = $builder->build( { source => 'Biblioitem', value => { biblionumber => $biblio->{biblionumber} } } ); >- >- my $item = $builder->build( >+ my $item = $builder->build_sample_item( > { >- source => 'Item', >- value => { >- homebranch => $library_1->{branchcode}, >- holdingbranch => $library_1->{branchcode}, >- notforloan => 0, >- itemlost => 0, >- withdrawn => 0, >- biblionumber => $biblioitem->{biblionumber}, >- } >+ library => $library_1->{branchcode}, > } >- ); >+ )->unblessed; > > set_userenv( $library_2 ); > my $reserve_id = AddReserve( >- $library_2->{branchcode}, $patron_2->{borrowernumber}, $biblioitem->{biblionumber}, >+ $library_2->{branchcode}, $patron_2->{borrowernumber}, $item->{biblionumber}, > '', 1, undef, undef, '', undef, $item->{itemnumber}, > ); > >@@ -2783,20 +2705,11 @@ subtest 'CanBookBeIssued | is_overdue' => sub { > my $library = $builder->build( { source => 'Branch' } ); > my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } ); > >- my $biblioitem = $builder->build( { source => 'Biblioitem' } ); >- my $item = $builder->build( >+ my $item = $builder->build_sample_item( > { >- source => 'Item', >- value => { >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- notforloan => 0, >- itemlost => 0, >- withdrawn => 0, >- biblionumber => $biblioitem->{biblionumber}, >- } >+ 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} } ); >@@ -2941,29 +2854,12 @@ subtest 'CanBookBeIssued | item-level_itypes=biblio' => sub { > my $library = $builder->build( { source => 'Branch' } ); > my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } )->store; > >- my $itemtype = $builder->build( >+ my $item = $builder->build_sample_item( > { >- source => 'Itemtype', >- value => { notforloan => undef, } >+ library => $library->{branchcode}, > } > ); > >- my $biblioitem = $builder->build( { source => 'Biblioitem', value => { itemtype => $itemtype->{itemtype} } } ); >- my $item = $builder->build_object( >- { >- class => 'Koha::Items', >- value => { >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- notforloan => 0, >- itemlost => 0, >- withdrawn => 0, >- biblionumber => $biblioitem->{biblionumber}, >- biblioitemnumber => $biblioitem->{biblioitemnumber}, >- } >- } >- )->store; >- > my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, undef, undef, undef, undef ); > is_deeply( $needsconfirmation, {}, 'Item can be issued to this patron' ); > is_deeply( $issuingimpossible, {}, 'Item can be issued to this patron' ); >@@ -2983,23 +2879,13 @@ subtest 'CanBookBeIssued | notforloan' => sub { > value => { notforloan => undef, } > } > ); >- >- my $biblioitem = $builder->build( { source => 'Biblioitem' } ); >- my $item = $builder->build_object( >+ my $item = $builder->build_sample_item( > { >- class => 'Koha::Items', >- value => { >- homebranch => $library->{branchcode}, >- holdingbranch => $library->{branchcode}, >- notforloan => 0, >- itemlost => 0, >- withdrawn => 0, >- itype => $itemtype->{itemtype}, >- biblionumber => $biblioitem->{biblionumber}, >- biblioitemnumber => $biblioitem->{biblioitemnumber}, >- } >+ library => $library->{branchcode}, >+ itype => $itemtype->{itemtype}, > } >- )->store; >+ ); >+ $item->biblioitem->itemtype($itemtype->{itemtype})->store; > > my ( $issuingimpossible, $needsconfirmation ); > >@@ -3084,7 +2970,12 @@ subtest 'AddReturn should clear items.onloan for unissued items' => sub { > plan tests => 1; > > t::lib::Mocks::mock_preference( "AllowReturnToBranch", 'anywhere' ); >- my $item = $builder->build_object({ class => 'Koha::Items', value => { onloan => '2018-01-01' }}); >+ my $item = $builder->build_sample_item( >+ { >+ onloan => '2018-01-01', >+ } >+ ); >+ > AddReturn( $item->barcode, $item->homebranch ); > $item->discard_changes; # refresh > is( $item->onloan, undef, 'AddReturn did clear items.onloan' ); >diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm >index 87caf63b0f..7ffd02f76e 100644 >--- a/t/lib/TestBuilder.pm >+++ b/t/lib/TestBuilder.pm >@@ -557,6 +557,7 @@ sub _gen_default_values { > rentalcharge_hourly => 0, > defaultreplacecost => 0, > processfee => 0, >+ notforloan => 0, > }, > Aqbookseller => { > tax_rate => 0, >-- >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 21985
:
83254
|
86634
|
86635
| 93259 |
93260
|
93261