Bugzilla – Attachment 140902 Details for
Bug 31105
Holds to pull counts items from other branches when independentbranches is active
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31105: Regression tests
Bug-31105-Regression-tests.patch (text/plain), 7.92 KB, created by
Tomás Cohen Arazi (tcohen)
on 2022-09-23 12:57:32 UTC
(
hide
)
Description:
Bug 31105: Regression tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2022-09-23 12:57:32 UTC
Size:
7.92 KB
patch
obsolete
>From aa4dc15b971e05612b12f17f4996a32be2b65f9c Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 23 Sep 2022 09:56:46 -0300 >Subject: [PATCH] Bug 31105: Regression tests > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/Koha/Items.t | 148 ++++++++++++++++++++---------------- > 1 file changed, 81 insertions(+), 67 deletions(-) > >diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t >index 76c9e33a277..6c1ebc3aac5 100755 >--- a/t/db_dependent/Koha/Items.t >+++ b/t/db_dependent/Koha/Items.t >@@ -1510,73 +1510,6 @@ subtest 'can_be_transferred' => sub { > 'We get the same result also if we pass the from-library parameter.'); > }; > >-subtest 'filter_by_for_hold' => sub { >- plan tests => 12; >- >- my $biblio = $builder->build_sample_biblio; >- is( $biblio->items->filter_by_for_hold->count, 0, 'no item yet' ); >- $builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => 1 } ); >- is( $biblio->items->filter_by_for_hold->count, 0, 'no item for hold' ); >- $builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => 0 } ); >- is( $biblio->items->filter_by_for_hold->count, 1, '1 item for hold' ); >- $builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => -1 } ); >- is( $biblio->items->filter_by_for_hold->count, 2, '2 items for hold' ); >- >- $builder->build_sample_item( { biblionumber => $biblio->biblionumber, itemlost => 0 } ); >- $builder->build_sample_item( { biblionumber => $biblio->biblionumber, itemlost => 1 } ); >- is( $biblio->items->filter_by_for_hold->count, 3, '3 items for hold - itemlost' ); >- >- $builder->build_sample_item( { biblionumber => $biblio->biblionumber, withdrawn => 0 } ); >- $builder->build_sample_item( { biblionumber => $biblio->biblionumber, withdrawn => 1 } ); >- is( $biblio->items->filter_by_for_hold->count, 4, '4 items for hold - withdrawn' ); >- >- $builder->build_sample_item( { biblionumber => $biblio->biblionumber, damaged => 0 } ); >- $builder->build_sample_item( { biblionumber => $biblio->biblionumber, damaged => 1 } ); >- t::lib::Mocks::mock_preference('AllowHoldsOnDamagedItems', 0); >- is( $biblio->items->filter_by_for_hold->count, 5, '5 items for hold - not damaged if not AllowHoldsOnDamagedItems' ); >- t::lib::Mocks::mock_preference('AllowHoldsOnDamagedItems', 1); >- is( $biblio->items->filter_by_for_hold->count, 6, '6 items for hold - damaged if AllowHoldsOnDamagedItems' ); >- >- my $itemtype = $builder->build_object({ class => 'Koha::ItemTypes' }); >- my $not_holdable_itemtype = $itemtype->itemtype; >- $builder->build_sample_item( >- { >- biblionumber => $biblio->biblionumber, >- itype => $not_holdable_itemtype, >- } >- ); >- Koha::CirculationRules->set_rule( >- { >- branchcode => undef, >- itemtype => $not_holdable_itemtype, >- rule_name => 'holdallowed', >- rule_value => 'not_allowed', >- } >- ); >- is( $biblio->items->filter_by_for_hold->count, 6, '6 items for hold - holdallowed=not_allowed' ); >- >- # Remove rule, test notforloan on itemtype >- Koha::CirculationRules->set_rule( >- { >- branchcode => undef, >- itemtype => $not_holdable_itemtype, >- rule_name => 'holdallowed', >- rule_value => undef, >- } >- ); >- is( $biblio->items->filter_by_for_hold->count, 7, '7 items for hold - rule deleted' ); >- $itemtype->notforloan(1)->store; >- is( $biblio->items->filter_by_for_hold->count, 6, '6 items for hold - notforloan' ); >- >- t::lib::Mocks::mock_preference('item-level_itypes', 0); >- $biblio->biblioitem->itemtype($not_holdable_itemtype)->store; >- is( $biblio->items->filter_by_for_hold->count, 0, '0 item-level_itypes=0' ); >- >- t::lib::Mocks::mock_preference('item-level_itypes', 1); >- >- $biblio->delete; >-}; >- > # Reset nb_of_items prior to testing delete > $nb_of_items = Koha::Items->search->count; > >@@ -1937,3 +1870,84 @@ subtest 'search_ordered' => sub { > $schema->storage->txn_rollback; > > }; >+ >+subtest 'filter_by_for_hold' => sub { >+ >+ plan tests => 13; >+ >+ $schema->storage->txn_begin; >+ >+ my $biblio = $builder->build_sample_biblio; >+ my $library = $builder->build_object({ class => 'Koha::Libraries' }); >+ >+ t::lib::Mocks::mock_preference('IndependentBranches', 0); # more robust tests >+ >+ is( $biblio->items->filter_by_for_hold->count, 0, 'no item yet' ); >+ $builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => 1 } ); >+ is( $biblio->items->filter_by_for_hold->count, 0, 'no item for hold' ); >+ $builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => 0 } ); >+ is( $biblio->items->filter_by_for_hold->count, 1, '1 item for hold' ); >+ $builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => -1 } ); >+ is( $biblio->items->filter_by_for_hold->count, 2, '2 items for hold' ); >+ >+ $builder->build_sample_item( { biblionumber => $biblio->biblionumber, itemlost => 0, library => $library->id } ); >+ $builder->build_sample_item( { biblionumber => $biblio->biblionumber, itemlost => 1, library => $library->id } ); >+ is( $biblio->items->filter_by_for_hold->count, 3, '3 items for hold - itemlost' ); >+ >+ $builder->build_sample_item( { biblionumber => $biblio->biblionumber, withdrawn => 0, library => $library->id } ); >+ $builder->build_sample_item( { biblionumber => $biblio->biblionumber, withdrawn => 1, library => $library->id } ); >+ is( $biblio->items->filter_by_for_hold->count, 4, '4 items for hold - withdrawn' ); >+ >+ $builder->build_sample_item( { biblionumber => $biblio->biblionumber, damaged => 0 } ); >+ $builder->build_sample_item( { biblionumber => $biblio->biblionumber, damaged => 1 } ); >+ t::lib::Mocks::mock_preference('AllowHoldsOnDamagedItems', 0); >+ is( $biblio->items->filter_by_for_hold->count, 5, '5 items for hold - not damaged if not AllowHoldsOnDamagedItems' ); >+ t::lib::Mocks::mock_preference('AllowHoldsOnDamagedItems', 1); >+ is( $biblio->items->filter_by_for_hold->count, 6, '6 items for hold - damaged if AllowHoldsOnDamagedItems' ); >+ >+ my $itemtype = $builder->build_object({ class => 'Koha::ItemTypes' }); >+ my $not_holdable_itemtype = $itemtype->itemtype; >+ $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ itype => $not_holdable_itemtype, >+ } >+ ); >+ Koha::CirculationRules->set_rule( >+ { >+ branchcode => undef, >+ itemtype => $not_holdable_itemtype, >+ rule_name => 'holdallowed', >+ rule_value => 'not_allowed', >+ } >+ ); >+ is( $biblio->items->filter_by_for_hold->count, 6, '6 items for hold - holdallowed=not_allowed' ); >+ >+ # Remove rule, test notforloan on itemtype >+ Koha::CirculationRules->set_rule( >+ { >+ branchcode => undef, >+ itemtype => $not_holdable_itemtype, >+ rule_name => 'holdallowed', >+ rule_value => undef, >+ } >+ ); >+ is( $biblio->items->filter_by_for_hold->count, 7, '7 items for hold - rule deleted' ); >+ $itemtype->notforloan(1)->store; >+ is( $biblio->items->filter_by_for_hold->count, 6, '6 items for hold - notforloan' ); >+ >+ { >+ my $mock_context = Test::MockModule->new('C4::Context'); >+ $mock_context->mock( 'only_my_library', 1 ); >+ $mock_context->mock( 'mybranch', $library->id ); >+ is( $biblio->items->filter_by_for_hold->count, 2, '2 items for hold, filtered by IndependentBranches' ); >+ } >+ >+ t::lib::Mocks::mock_preference('item-level_itypes', 0); >+ $biblio->biblioitem->itemtype($not_holdable_itemtype)->store; >+ is( $biblio->items->filter_by_for_hold->count, 0, '0 item-level_itypes=0' ); >+ >+ t::lib::Mocks::mock_preference('item-level_itypes', 1); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 31105
:
137181
|
137859
|
139496
| 140902