Bugzilla – Attachment 58228 Details for
Bug 17783
Optimize Koha::IssuingRules->get_effective_issuing_rule
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17783: Test to confirm correct effective issuing rule selection
Bug-17783-Test-to-confirm-correct-effective-issuin.patch (text/plain), 7.73 KB, created by
Lari Taskula
on 2016-12-15 17:43:40 UTC
(
hide
)
Description:
Bug 17783: Test to confirm correct effective issuing rule selection
Filename:
MIME Type:
Creator:
Lari Taskula
Created:
2016-12-15 17:43:40 UTC
Size:
7.73 KB
patch
obsolete
>From a3211e43e41da2d9387c4aa8e785cd1e6d0f7193 Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@jns.fi> >Date: Thu, 15 Dec 2016 17:58:39 +0200 >Subject: [PATCH] Bug 17783: Test to confirm correct effective issuing rule > selection > >This patch adds a test to cover the validity of effective issuing rule selection >in correct order. > >To test: >1. Run t/db_dependent/Koha/IssuingRules.t >--- > t/db_dependent/Koha/IssuingRules.t | 172 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 172 insertions(+) > create mode 100644 t/db_dependent/Koha/IssuingRules.t > >diff --git a/t/db_dependent/Koha/IssuingRules.t b/t/db_dependent/Koha/IssuingRules.t >new file mode 100644 >index 0000000..1d48fff >--- /dev/null >+++ b/t/db_dependent/Koha/IssuingRules.t >@@ -0,0 +1,172 @@ >+#!/usr/bin/perl >+ >+# Copyright 2016 Koha-Suomi Oy >+# >+# 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 Koha::IssuingRules; >+ >+use t::lib::TestBuilder; >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+my $builder = t::lib::TestBuilder->new; >+ >+subtest 'get_effective_issuing_rule' => sub { >+ plan tests => 1; >+ >+ my $patron = $builder->build({ source => 'Borrower' }); >+ my $item = $builder->build({ source => 'Item' }); >+ >+ my $categorycode = $patron->{'categorycode'}; >+ my $itemtype = $item->{'itype'}; >+ my $branchcode = $item->{'homebranch'}; >+ >+ subtest 'Get effective issuing rule in correct order' => sub { >+ plan tests => 18; >+ >+ my $rule; >+ Koha::IssuingRules->delete; >+ ok(!Koha::IssuingRules->search->count, 'There are no issuing rules.'); >+ $rule = Koha::IssuingRules->get_effective_issuing_rule({ >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ }); >+ is($rule, undef, 'When I attempt to get effective issuing rule, then undef' >+ .' is returned.'); >+ >+ ok(Koha::IssuingRule->new({ >+ branchcode => '*', >+ categorycode => '*', >+ itemtype => '*', >+ })->store, 'Given I added an issuing rule branchcode => *, categorycode => *, itemtype => *,'); >+ $rule = Koha::IssuingRules->get_effective_issuing_rule({ >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ }); >+ ok(_row_match($rule, '*', '*', '*'), 'When I attempt to get effective issuing rule,' >+ .' then the above one is returned.'); >+ >+ ok(Koha::IssuingRule->new({ >+ branchcode => '*', >+ categorycode => '*', >+ itemtype => $itemtype, >+ })->store, "Given I added an issuing rule branchcode => *, categorycode => *, itemtype => $itemtype,"); >+ $rule = Koha::IssuingRules->get_effective_issuing_rule({ >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ }); >+ ok(_row_match($rule, '*', '*', $itemtype), 'When I attempt to get effective issuing rule,' >+ .' then the above one is returned.'); >+ >+ ok(Koha::IssuingRule->new({ >+ branchcode => '*', >+ categorycode => $categorycode, >+ itemtype => '*', >+ })->store, "Given I added an issuing rule branchcode => *, categorycode => $categorycode, itemtype => *,"); >+ $rule = Koha::IssuingRules->get_effective_issuing_rule({ >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ }); >+ ok(_row_match($rule, '*', $categorycode, '*'), 'When I attempt to get effective issuing rule,' >+ .' then the above one is returned.'); >+ >+ ok(Koha::IssuingRule->new({ >+ branchcode => '*', >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ })->store, "Given I added an issuing rule branchcode => *, categorycode => $categorycode, itemtype => $itemtype,"); >+ $rule = Koha::IssuingRules->get_effective_issuing_rule({ >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ }); >+ ok(_row_match($rule, '*', $categorycode, $itemtype), 'When I attempt to get effective issuing rule,' >+ .' then the above one is returned.'); >+ >+ ok(Koha::IssuingRule->new({ >+ branchcode => $branchcode, >+ categorycode => '*', >+ itemtype => '*', >+ })->store, "Given I added an issuing rule branchcode => $branchcode, categorycode => '*', itemtype => '*',"); >+ $rule = Koha::IssuingRules->get_effective_issuing_rule({ >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ }); >+ ok(_row_match($rule, $branchcode, '*', '*'), 'When I attempt to get effective issuing rule,' >+ .' then the above one is returned.'); >+ >+ ok(Koha::IssuingRule->new({ >+ branchcode => $branchcode, >+ categorycode => '*', >+ itemtype => $itemtype, >+ })->store, "Given I added an issuing rule branchcode => $branchcode, categorycode => '*', itemtype => $itemtype,"); >+ $rule = Koha::IssuingRules->get_effective_issuing_rule({ >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ }); >+ ok(_row_match($rule, $branchcode, '*', $itemtype), 'When I attempt to get effective issuing rule,' >+ .' then the above one is returned.'); >+ >+ ok(Koha::IssuingRule->new({ >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => '*', >+ })->store, "Given I added an issuing rule branchcode => $branchcode, categorycode => $categorycode, itemtype => '*',"); >+ $rule = Koha::IssuingRules->get_effective_issuing_rule({ >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ }); >+ ok(_row_match($rule, $branchcode, $categorycode, '*'), 'When I attempt to get effective issuing rule,' >+ .' then the above one is returned.'); >+ >+ ok(Koha::IssuingRule->new({ >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ })->store, "Given I added an issuing rule branchcode => $branchcode, categorycode => $categorycode, itemtype => $itemtype,"); >+ $rule = Koha::IssuingRules->get_effective_issuing_rule({ >+ branchcode => $branchcode, >+ categorycode => $categorycode, >+ itemtype => $itemtype, >+ }); >+ ok(_row_match($rule, $branchcode, $categorycode, $itemtype), 'When I attempt to get effective issuing rule,' >+ .' then the above one is returned.'); >+ }; >+}; >+ >+sub _row_match { >+ my ($rule, $branchcode, $categorycode, $itemtype) = @_; >+ >+ return $rule->branchcode eq $branchcode && $rule->categorycode eq $categorycode >+ && $rule->itemtype eq $itemtype; >+} >+ >+$schema->storage->txn_rollback; >+ >+1; >-- >1.9.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 17783
:
58228
|
58229
|
58230
|
58231
|
58268
|
58269
|
58270
|
58271
|
58300
|
58304
|
58309
|
58310
|
58311
|
58312
|
58313
|
58314