Bugzilla – Attachment 79776 Details for
Bug 18887
Introduce new table 'circulation_rules', use for 'max_holds' rules
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18887: Add tests
Bug-18887-Add-tests.patch (text/plain), 7.78 KB, created by
Josef Moravec
on 2018-10-01 19:36:36 UTC
(
hide
)
Description:
Bug 18887: Add tests
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2018-10-01 19:36:36 UTC
Size:
7.78 KB
patch
obsolete
>From 1117edfb0edf48288fcfa6c2d348e09b6645f8b8 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Sat, 29 Sep 2018 18:18:03 -0300 >Subject: [PATCH] Bug 18887: Add tests > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > t/db_dependent/Koha/CirculationRules.t | 237 +++++++++++++++++++++++++++++++++ > 1 file changed, 237 insertions(+) > create mode 100644 t/db_dependent/Koha/CirculationRules.t > >diff --git a/t/db_dependent/Koha/CirculationRules.t b/t/db_dependent/Koha/CirculationRules.t >new file mode 100644 >index 0000000..962bf0b >--- /dev/null >+++ b/t/db_dependent/Koha/CirculationRules.t >@@ -0,0 +1,237 @@ >+#!/usr/bin/perl >+ >+# Copyright 2018 Koha Development team >+# >+# This file is part of Koha >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 1; >+use Test::Exception; >+ >+use Koha::CirculationRules; >+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 => 11; >+ >+ 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; >+ my $rule_name = 'my_rule'; >+ my $default_rule_value = 1; >+ >+ my $rule; >+ Koha::CirculationRules->delete; >+ >+ throws_ok { Koha::CirculationRules->get_effective_rule } >+ 'Koha::Exceptions::MissingParameter', >+ "Exception should be raised if get_effective_rule is called without rule_name parameter"; >+ >+ $rule = Koha::CirculationRules->get_effective_rule( >+ { >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ rule_name => $rule_name, >+ } >+ ); >+ is( $rule, undef, 'Undef should be returned if no rule exist' ); >+ >+ Koha::CirculationRules->set_rule( >+ { >+ branchcode => '*', >+ categorycode => '*', >+ itemtype => '*', >+ rule_name => $rule_name, >+ rule_value => $default_rule_value, >+ } >+ ); >+ >+ $rule = Koha::CirculationRules->get_effective_rule( >+ { >+ branchcode => undef, >+ categorycode => undef, >+ itemtype => undef, >+ rule_name => $rule_name, >+ } >+ ); >+ is( $rule->rule_value, $default_rule_value, 'undef means default' ); >+ $rule = Koha::CirculationRules->get_effective_rule( >+ { >+ branchcode => '*', >+ categorycode => '*', >+ itemtype => '*', >+ rule_name => $rule_name, >+ } >+ ); >+ >+ is( $rule->rule_value, $default_rule_value, '* means default' ); >+ >+ Koha::CirculationRules->set_rule( >+ { >+ branchcode => '*', >+ categorycode => '*', >+ itemtype => $itemtype, >+ rule_name => $rule_name, >+ rule_value => 2, >+ } >+ ); >+ >+ $rule = Koha::CirculationRules->get_effective_rule( >+ { >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ rule_name => $rule_name, >+ } >+ ); >+ is( $rule->rule_value, 2, >+ 'More specific rule is returned when itemtype is given' ); >+ >+ Koha::CirculationRules->set_rule( >+ { >+ branchcode => '*', >+ categorycode => $categorycode, >+ itemtype => '*', >+ rule_name => $rule_name, >+ rule_value => 3, >+ } >+ ); >+ >+ $rule = Koha::CirculationRules->get_effective_rule( >+ { >+ >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ rule_name => $rule_name, >+ } >+ ); >+ is( $rule->rule_value, 3, >+ 'More specific rule is returned when categorycode exists' ); >+ >+ Koha::CirculationRules->set_rule( >+ { >+ branchcode => '*', >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ rule_name => $rule_name, >+ rule_value => 4, >+ } >+ ); >+ $rule = Koha::CirculationRules->get_effective_rule( >+ { >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ rule_name => $rule_name, >+ } >+ ); >+ is( $rule->rule_value, 4, >+ 'More specific rule is returned when categorycode and itemtype exist' ); >+ >+ Koha::CirculationRules->set_rule( >+ { >+ branchcode => $branchcode, >+ categorycode => '*', >+ itemtype => '*', >+ rule_name => $rule_name, >+ rule_value => 5, >+ } >+ ); >+ $rule = Koha::CirculationRules->get_effective_rule( >+ { >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ rule_name => $rule_name, >+ } >+ ); >+ is( $rule->rule_value, 5, >+ 'More specific rule is returned when branchcode exists' ); >+ >+ Koha::CirculationRules->set_rule( >+ { >+ branchcode => $branchcode, >+ categorycode => '*', >+ itemtype => $itemtype, >+ rule_name => $rule_name, >+ rule_value => 6, >+ } >+ ); >+ $rule = Koha::CirculationRules->get_effective_rule( >+ { >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ rule_name => $rule_name, >+ } >+ ); >+ is( $rule->rule_value, 6, >+ 'More specific rule is returned when branchcode and itemtype exists' ); >+ >+ Koha::CirculationRules->set_rule( >+ { >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => '*', >+ rule_name => $rule_name, >+ rule_value => 7, >+ } >+ ); >+ $rule = Koha::CirculationRules->get_effective_rule( >+ { >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ rule_name => $rule_name, >+ } >+ ); >+ is( $rule->rule_value, 7, >+ 'More specific rule is returned when branchcode and categorycode exist' >+ ); >+ >+ Koha::CirculationRules->set_rule( >+ { >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ rule_name => $rule_name, >+ rule_value => 8, >+ } >+ ); >+ $rule = Koha::CirculationRules->get_effective_rule( >+ { >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ rule_name => $rule_name, >+ } >+ ); >+ is( $rule->rule_value, 8, >+ 'More specific rule is returned when branchcode, categorycode and itemtype exist' >+ ); >+}; >+ >+$schema->storage->txn_rollback; >-- >2.1.4
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 18887
:
65233
|
65234
|
65235
|
65236
|
65237
|
67620
|
70986
|
70987
|
70988
|
70989
|
70990
|
70991
|
71031
|
71042
|
72218
|
72219
|
72220
|
72221
|
72222
|
72223
|
72224
|
77080
|
77081
|
77082
|
77083
|
77084
|
77085
|
77086
|
77087
|
77207
|
77208
|
77209
|
77210
|
77211
|
77212
|
77213
|
77214
|
77215
|
77218
|
77238
|
77649
|
77650
|
77651
|
77652
|
77653
|
77654
|
77655
|
77656
|
77657
|
77658
|
77659
|
78346
|
78347
|
78348
|
78349
|
78350
|
78351
|
78352
|
78353
|
78354
|
78355
|
78356
|
78674
|
78675
|
78676
|
78677
|
78678
|
78679
|
78680
|
78681
|
78682
|
78683
|
78684
|
78743
|
78744
|
78745
|
78746
|
78747
|
78748
|
78749
|
78750
|
78751
|
78752
|
78753
|
78879
|
79119
|
79626
|
79627
|
79628
|
79629
|
79630
|
79631
|
79632
|
79633
|
79634
|
79635
|
79636
|
79637
|
79638
|
79639
|
79640
|
79641
|
79761
|
79762
|
79763
|
79764
|
79765
|
79766
|
79767
|
79768
|
79769
|
79770
|
79771
|
79772
|
79773
|
79774
|
79775
| 79776 |
79778
|
79891