Bugzilla – Attachment 164936 Details for
Bug 29087
Holds to pull list can crash with a SQL::Abstract puke
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29087: Add unit tests
Bug-29087-Add-unit-tests.patch (text/plain), 6.74 KB, created by
Matt Blenkinsop
on 2024-04-16 13:25:03 UTC
(
hide
)
Description:
Bug 29087: Add unit tests
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2024-04-16 13:25:03 UTC
Size:
6.74 KB
patch
obsolete
>From a81c39be9a8c70eddaa2c80308a0c8aadbef44a7 Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Tue, 16 Apr 2024 12:47:16 +0000 >Subject: [PATCH] Bug 29087: Add unit tests > >prove t/db_dependent/Koha/Items.t >--- > t/db_dependent/Koha/Items.t | 116 ++++++++++++------------------------ > 1 file changed, 37 insertions(+), 79 deletions(-) > >diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t >index 5a03e9592d..e424150c13 100755 >--- a/t/db_dependent/Koha/Items.t >+++ b/t/db_dependent/Koha/Items.t >@@ -1554,80 +1554,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; >- >- Koha::CirculationRules->search( >- { >- rule_name => 'holdallowed', >- rule_value => 'not_allowed', >- } >- )->delete; >- >- 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; > >@@ -1987,16 +1913,50 @@ subtest 'search_ordered' => sub { > > subtest 'filter_by_for_hold' => sub { > >- plan tests => 13; >+ plan tests => 15; > > $schema->storage->txn_begin; > >+ # Set default rule >+ Koha::CirculationRules->set_rule( >+ { >+ branchcode => undef, >+ itemtype => undef, >+ rule_name => 'holdallowed', >+ rule_value => 'not_allowed', >+ } >+ ); >+ my $itemtype = $builder->build_object({ class => 'Koha::ItemTypes' }); >+ my $not_holdable_itemtype = $itemtype->itemtype; >+ my $itemtype2 = $builder->build_object({ class => 'Koha::ItemTypes' }); >+ my $holdable_itemtype = $itemtype2->itemtype; >+ Koha::CirculationRules->set_rule( >+ { >+ branchcode => undef, >+ itemtype => $holdable_itemtype, >+ rule_name => 'holdallowed', >+ rule_value => 'from_any_library', >+ } >+ ); >+ > 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 => 0, itype => $not_holdable_itemtype } ); >+ is( $biblio->items->filter_by_for_hold->count, 0, 'default rule prevents hold' ); >+ $builder->build_sample_item( { 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 } ); >@@ -2019,8 +1979,6 @@ subtest 'filter_by_for_hold' => sub { > 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, >-- >2.37.1 (Apple Git-137.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 29087
:
127859
|
164936
|
166354
|
166355
|
166359
|
166360
|
166527
|
166528
|
168241
|
168242
|
169179
|
169180
|
169181