Bugzilla – Attachment 98532 Details for
Bug 24602
The fallback value for onshelfholds should be 0
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24602: Tests for get_onshlefholds_policy
Bug-24602-Tests-for-getonshlefholdspolicy.patch (text/plain), 2.62 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-02-06 14:19:03 UTC
(
hide
)
Description:
Bug 24602: Tests for get_onshlefholds_policy
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-02-06 14:19:03 UTC
Size:
2.62 KB
patch
obsolete
>From d3aa8e303747e790800017c62f46bcac3602f26f Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 6 Feb 2020 11:09:12 -0300 >Subject: [PATCH] Bug 24602: Tests for get_onshlefholds_policy > >Ths patch introduces tests for get_onshelf_policy. >To test: >1. Apply this patch >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/CirculationRules.t >=> FAIL: Tests fail because the current code returns undef instead of 0 >--- > t/db_dependent/Koha/CirculationRules.t | 38 ++++++++++++++++++++++---- > 1 file changed, 33 insertions(+), 5 deletions(-) > >diff --git a/t/db_dependent/Koha/CirculationRules.t b/t/db_dependent/Koha/CirculationRules.t >index 460868f671..7e27b59feb 100644 >--- a/t/db_dependent/Koha/CirculationRules.t >+++ b/t/db_dependent/Koha/CirculationRules.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 1; >+use Test::More tests => 2; > use Test::Exception; > > use Koha::CirculationRules; >@@ -28,13 +28,13 @@ use Koha::Database; > use t::lib::TestBuilder; > > my $schema = Koha::Database->new->schema; >-$schema->storage->txn_begin; >- > my $builder = t::lib::TestBuilder->new; > > subtest 'set_rule + get_effective_rule' => sub { > plan tests => 14; > >+ $schema->storage->txn_begin; >+ > my $categorycode = $builder->build_object( { class => 'Koha::Patron::Categories' } )->categorycode; > my $itemtype = $builder->build_object( { class => 'Koha::ItemTypes' } )->itemtype; > my $branchcode = $builder->build_object( { class => 'Koha::Libraries' } )->branchcode; >@@ -250,7 +250,35 @@ subtest 'set_rule + get_effective_rule' => sub { > $our_branch_rules->delete; > is( $our_branch_rules->count, 0, "We deleted 8 rules"); > >- >+ $schema->storage->txn_rollback; > }; > >-$schema->storage->txn_rollback; >+subtest 'get_onshelfholds_policy() tests' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $item = $builder->build_sample_item(); >+ >+ my $circ_rules = Koha::CirculationRules->new; >+ # Cleanup >+ $circ_rules->search({ rule_name => 'onshelfholds' })->delete; >+ >+ $circ_rules->set_rule( >+ { >+ branchcode => '*', >+ categorycode => '*', >+ itemtype => '*', >+ rule_name => 'onshelfholds', >+ rule_value => 1, >+ } >+ ); >+ >+ is( $circ_rules->get_onshelfholds_policy({ item => $item }), 1, 'If rule_value is set on a matching rule, return it' ); >+ # Delete the rule (i.e. get_effective_rule returns undef) >+ $circ_rules->delete; >+ is( $circ_rules->get_onshelfholds_policy({ item => $item }), 0, 'If no matching rule, fallback to 0' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.25.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 24602
:
98532
|
98533
|
98554
|
98555
|
98578
|
98579