Bugzilla – Attachment 173183 Details for
Bug 38148
Check value of holdallowed circ rule properly (Bug 29087 follow-up)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38148: Unit tests
Bug-38148-Unit-tests.patch (text/plain), 7.67 KB, created by
Nick Clemens (kidclamp)
on 2024-10-22 20:08:49 UTC
(
hide
)
Description:
Bug 38148: Unit tests
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2024-10-22 20:08:49 UTC
Size:
7.67 KB
patch
obsolete
>From 8b7c666de702678367a19827a8f7810dd87ff67c Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 22 Oct 2024 19:54:42 +0000 >Subject: [PATCH] Bug 38148: Unit tests > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > t/db_dependent/Koha/Items.t | 126 +++++++++++++++++++++++++++--------- > 1 file changed, 95 insertions(+), 31 deletions(-) > >diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t >index 58e1c1f113f..6112f7dcfec 100755 >--- a/t/db_dependent/Koha/Items.t >+++ b/t/db_dependent/Koha/Items.t >@@ -1998,7 +1998,7 @@ subtest 'search_ordered' => sub { > > subtest 'filter_by_for_hold' => sub { > >- plan tests => 15; >+ plan tests => 10; > > $schema->storage->txn_begin; > >@@ -2035,36 +2035,100 @@ subtest 'filter_by_for_hold' => sub { > { biblionumber => $biblio->biblionumber, notforloan => 0, itype => $holdable_itemtype } ); > is( $biblio->items->filter_by_for_hold->count, 1, 'hold allowed despite default rule' ); > >- # Reset items and circ rules to remove default rule >- $biblio->items->delete; >- Koha::CirculationRules->search( >- { >- rule_name => 'holdallowed', >- rule_value => 'not_allowed', >- } >- )->delete; >- >- $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' ); >+ subtest "No default rule" => sub { >+ plan tests => 7; >+ >+ # Reset items and circ rules to remove default rule >+ $biblio->items->delete; >+ Koha::CirculationRules->search( >+ { >+ rule_name => 'holdallowed', >+ rule_value => 'not_allowed', >+ } >+ )->delete; >+ >+ $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' ); >+ }; >+ >+ subtest "Default rule from_any_library" => sub { >+ >+ plan tests => 7; >+ >+ $biblio->items->delete; >+ Koha::CirculationRules->set_rule( >+ { >+ branchcode => undef, >+ itemtype => undef, >+ rule_name => 'holdallowed', >+ rule_value => 'from_any_library', >+ } >+ ); >+ >+ $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' ); >+ >+ Koha::CirculationRules->search( >+ { >+ rule_name => 'holdallowed', >+ branchcode => undef, >+ itemtype => undef, >+ rule_value => 'from_any_library', >+ } >+ )->delete; >+ }; > > $builder->build_sample_item( > { >-- >2.39.5
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 38148
:
172680
|
172681
|
172929
|
173125
|
173141
|
173142
|
173143
|
173144
|
173169
|
173170
|
173183
|
173184
|
173185
|
173205
|
173206
|
173207
|
173208