3 # Copyright 2020 Koha Development team
5 # This file is part of Koha
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
23 use Test::More tests => 8;
24 use Test::Deep qw( cmp_methods );
27 use Koha::CirculationRules;
31 use t::lib::TestBuilder;
33 my $schema = Koha::Database->new->schema;
34 my $builder = t::lib::TestBuilder->new;
36 subtest 'get_effective_issuing_rule' => sub {
39 $schema->storage->txn_begin;
41 my $categorycode = $builder->build({ source => 'Category' })->{'categorycode'};
42 my $itemtype = $builder->build({ source => 'Itemtype' })->{'itemtype'};
43 my $branchcode = $builder->build({ source => 'Branch' })->{'branchcode'};
45 subtest 'Call with undefined values' => sub {
49 Koha::CirculationRules->delete;
51 is(Koha::CirculationRules->search->count, 0, 'There are no issuing rules.');
52 # undef, undef, undef => 1
53 $rule = Koha::CirculationRules->get_effective_rule({
55 categorycode => undef,
60 is($rule, undef, 'When I attempt to get effective issuing rule by'
61 .' providing undefined values, then undef is returned.');
63 # undef, undef, undef => 2
65 Koha::CirculationRule->new(
68 categorycode => undef,
74 'Given I added an issuing rule branchcode => undef,'
75 .' categorycode => undef, itemtype => undef,');
76 $rule = Koha::CirculationRules->get_effective_rule({
78 categorycode => undef,
86 categorycode => undef,
91 'When I attempt to get effective'
92 .' issuing rule by providing undefined values, then the above one is'
97 subtest 'Performance' => sub {
100 my $worst_case = timethis(500,
101 sub { Koha::CirculationRules->get_effective_rule({
102 branchcode => 'nonexistent',
103 categorycode => 'nonexistent',
104 itemtype => 'nonexistent',
105 rule_name => 'nonexistent',
109 my $mid_case = timethis(500,
110 sub { Koha::CirculationRules->get_effective_rule({
111 branchcode => $branchcode,
112 categorycode => 'nonexistent',
113 itemtype => 'nonexistent',
114 rule_name => 'nonexistent',
118 my $sec_best_case = timethis(500,
119 sub { Koha::CirculationRules->get_effective_rule({
120 branchcode => $branchcode,
121 categorycode => $categorycode,
122 itemtype => 'nonexistent',
123 rule_name => 'nonexistent',
127 my $best_case = timethis(500,
128 sub { Koha::CirculationRules->get_effective_rule({
129 branchcode => $branchcode,
130 categorycode => $categorycode,
131 itemtype => $itemtype,
132 rule_name => 'nonexistent',
136 ok($worst_case, 'In worst case, get_effective_issuing_rule finds matching'
137 .' rule '.sprintf('%.2f', $worst_case->iters/$worst_case->cpu_a)
138 .' times per second.');
139 ok($mid_case, 'In mid case, get_effective_issuing_rule finds matching'
140 .' rule '.sprintf('%.2f', $mid_case->iters/$mid_case->cpu_a)
141 .' times per second.');
142 ok($sec_best_case, 'In second best case, get_effective_issuing_rule finds matching'
143 .' rule '.sprintf('%.2f', $sec_best_case->iters/$sec_best_case->cpu_a)
144 .' times per second.');
145 ok($best_case, 'In best case, get_effective_issuing_rule finds matching'
146 .' rule '.sprintf('%.2f', $best_case->iters/$best_case->cpu_a)
147 .' times per second.');
150 $schema->storage->txn_rollback;
154 subtest 'set_rule' => sub {
157 $schema->storage->txn_begin;
159 my $branchcode = $builder->build({ source => 'Branch' })->{'branchcode'};
160 my $categorycode = $builder->build({ source => 'Category' })->{'categorycode'};
161 my $itemtype = $builder->build({ source => 'Itemtype' })->{'itemtype'};
163 subtest 'Correct call' => sub {
166 Koha::CirculationRules->delete;
169 Koha::CirculationRules->set_rule( {
170 branchcode => $branchcode,
171 rule_name => 'lostreturn',
174 }, 'setting lostreturn with branch' );
177 Koha::CirculationRules->set_rule( {
178 branchcode => $branchcode,
179 rule_name => 'processingreturn',
182 }, 'setting processingreturn with branch' );
185 Koha::CirculationRules->set_rule( {
186 branchcode => $branchcode,
187 categorycode => $categorycode,
188 rule_name => 'patron_maxissueqty',
191 }, 'setting patron_maxissueqty with branch/category succeeds' );
194 Koha::CirculationRules->set_rule( {
195 branchcode => $branchcode,
196 itemtype => $itemtype,
197 rule_name => 'holdallowed',
200 }, 'setting holdallowed with branch/itemtype succeeds' );
203 Koha::CirculationRules->set_rule( {
204 branchcode => $branchcode,
205 categorycode => $categorycode,
206 itemtype => $itemtype,
210 }, 'setting fine with branch/category/itemtype succeeds' );
213 subtest 'Call with missing params' => sub {
216 Koha::CirculationRules->delete;
219 Koha::CirculationRules->set_rule( {
220 rule_name => 'lostreturn',
223 }, qr/branchcode/, 'setting lostreturn without branch fails' );
226 Koha::CirculationRules->set_rule( {
227 rule_name => 'processingreturn',
230 }, qr/branchcode/, 'setting processingreturn without branch fails' );
233 Koha::CirculationRules->set_rule( {
234 branchcode => $branchcode,
235 rule_name => 'patron_maxissueqty',
238 }, qr/categorycode/, 'setting patron_maxissueqty without categorycode fails' );
241 Koha::CirculationRules->set_rule( {
242 branchcode => $branchcode,
243 rule_name => 'holdallowed',
246 }, qr/itemtype/, 'setting holdallowed without itemtype fails' );
249 Koha::CirculationRules->set_rule( {
250 branchcode => $branchcode,
251 categorycode => $categorycode,
255 }, qr/itemtype/, 'setting fine without itemtype fails' );
258 subtest 'Call with extra params' => sub {
261 Koha::CirculationRules->delete;
264 Koha::CirculationRules->set_rule( {
265 branchcode => $branchcode,
266 categorycode => $categorycode,
267 rule_name => 'lostreturn',
270 }, qr/categorycode/, 'setting lostreturn with categorycode fails' );
273 Koha::CirculationRules->set_rule( {
274 branchcode => $branchcode,
275 categorycode => $categorycode,
276 rule_name => 'processingreturn',
279 }, qr/categorycode/, 'setting processingreturn with categorycode fails' );
282 Koha::CirculationRules->set_rule( {
283 branchcode => $branchcode,
284 categorycode => $categorycode,
285 itemtype => $itemtype,
286 rule_name => 'patron_maxissueqty',
289 }, qr/itemtype/, 'setting patron_maxissueqty with itemtype fails' );
292 Koha::CirculationRules->set_rule( {
293 branchcode => $branchcode,
294 rule_name => 'holdallowed',
295 categorycode => $categorycode,
296 itemtype => $itemtype,
299 }, qr/categorycode/, 'setting holdallowed with categorycode fails' );
302 $schema->storage->txn_rollback;
305 subtest 'clone' => sub {
308 $schema->storage->txn_begin;
310 my $branchcode = $builder->build({ source => 'Branch' })->{'branchcode'};
311 my $categorycode = $builder->build({ source => 'Category' })->{'categorycode'};
312 my $itemtype = $builder->build({ source => 'Itemtype' })->{'itemtype'};
314 subtest 'Clone multiple rules' => sub {
317 Koha::CirculationRules->delete;
319 Koha::CirculationRule->new({
321 categorycode => $categorycode,
322 itemtype => $itemtype,
327 Koha::CirculationRule->new({
329 categorycode => $categorycode,
330 itemtype => $itemtype,
331 rule_name => 'lengthunit',
332 rule_value => 'days',
335 Koha::CirculationRules->search({ branchcode => undef })->clone($branchcode);
337 my $rule_fine = Koha::CirculationRules->get_effective_rule({
338 branchcode => $branchcode,
339 categorycode => $categorycode,
340 itemtype => $itemtype,
343 my $rule_lengthunit = Koha::CirculationRules->get_effective_rule({
344 branchcode => $branchcode,
345 categorycode => $categorycode,
346 itemtype => $itemtype,
347 rule_name => 'lengthunit',
353 branchcode => $branchcode,
354 categorycode => $categorycode,
355 itemtype => $itemtype,
359 'When I attempt to get cloned fine rule,'
360 .' then the above one is returned.'
365 branchcode => $branchcode,
366 categorycode => $categorycode,
367 itemtype => $itemtype,
368 rule_name => 'lengthunit',
369 rule_value => 'days',
371 'When I attempt to get cloned lengthunit rule,'
372 .' then the above one is returned.'
377 subtest 'Clone one rule' => sub {
380 Koha::CirculationRules->delete;
382 Koha::CirculationRule->new({
384 categorycode => $categorycode,
385 itemtype => $itemtype,
390 my $rule = Koha::CirculationRules->search({ branchcode => undef })->next;
391 $rule->clone($branchcode);
393 my $cloned_rule = Koha::CirculationRules->get_effective_rule({
394 branchcode => $branchcode,
395 categorycode => $categorycode,
396 itemtype => $itemtype,
403 branchcode => $branchcode,
404 categorycode => $categorycode,
405 itemtype => $itemtype,
409 'When I attempt to get cloned fine rule,'
410 .' then the above one is returned.'
415 $schema->storage->txn_rollback;
418 subtest 'set_rule + get_effective_rule' => sub {
421 $schema->storage->txn_begin;
423 my $categorycode = $builder->build_object( { class => 'Koha::Patron::Categories' } )->categorycode;
424 my $itemtype = $builder->build_object( { class => 'Koha::ItemTypes' } )->itemtype;
425 my $branchcode = $builder->build_object( { class => 'Koha::Libraries' } )->branchcode;
426 my $branchcode_2 = $builder->build_object( { class => 'Koha::Libraries' } )->branchcode;
427 my $rule_name = 'maxissueqty';
428 my $default_rule_value = 1;
431 Koha::CirculationRules->delete;
433 throws_ok { Koha::CirculationRules->get_effective_rule }
434 'Koha::Exceptions::MissingParameter',
435 "Exception should be raised if get_effective_rule is called without rule_name parameter";
437 $rule = Koha::CirculationRules->get_effective_rule(
439 branchcode => $branchcode,
440 categorycode => $categorycode,
441 itemtype => $itemtype,
442 rule_name => $rule_name,
445 is( $rule, undef, 'Undef should be returned if no rule exist' );
447 Koha::CirculationRules->set_rule(
452 rule_name => $rule_name,
453 rule_value => $default_rule_value,
457 $rule = Koha::CirculationRules->get_effective_rule(
460 categorycode => undef,
462 rule_name => $rule_name,
465 is( $rule->rule_value, $default_rule_value, 'undef means default' );
466 $rule = Koha::CirculationRules->get_effective_rule(
471 rule_name => $rule_name,
475 is( $rule->rule_value, $default_rule_value, '* means default' );
477 $rule = Koha::CirculationRules->get_effective_rule(
479 branchcode => $branchcode_2,
482 rule_name => $rule_name,
485 is( $rule->rule_value, 1,
486 'Default rule is returned if there is no rule for this branchcode' );
488 subtest 'test rules that cannot be blank' => sub {
490 foreach my $no_blank_rule ( ('holdallowed','hold_fulfillment_policy','returnbranch') ){
491 Koha::CirculationRules->set_rule(
493 branchcode => $branchcode,
495 rule_name => $no_blank_rule,
500 $rule = Koha::CirculationRules->get_effective_rule(
502 branchcode => $branchcode,
503 categorycode => undef,
505 rule_name => $no_blank_rule,
508 is( $rule, undef, 'Rules that cannot be blank are not set when passed blank string' );
513 subtest 'test rule matching with different combinations of rule scopes' => sub {
514 my ( $tests, $order ) = _prepare_tests_for_rule_scope_combinations(
516 branchcode => $branchcode,
517 categorycode => $categorycode,
518 itemtype => $itemtype,
523 plan tests => 2**scalar @$order;
525 foreach my $test (@$tests) {
526 my $rule_params = {%$test};
527 $rule_params->{rule_name} = $rule_name;
528 my $rule_value = $rule_params->{rule_value} = int( rand(10) );
530 Koha::CirculationRules->set_rule($rule_params);
532 my $rule = Koha::CirculationRules->get_effective_rule(
534 branchcode => $branchcode,
535 categorycode => $categorycode,
536 itemtype => $itemtype,
537 rule_name => $rule_name,
541 my $scope_output = '';
542 foreach my $key ( values @$order ) {
543 $scope_output .= " $key" if $test->{$key} ne '*';
546 is( $rule->rule_value, $rule_value,
548 . ( $scope_output ? $scope_output : ' nothing' ) );
552 my $our_branch_rules = Koha::CirculationRules->search({branchcode => $branchcode});
553 is( $our_branch_rules->count, 4, "We added 8 rules");
554 $our_branch_rules->delete;
555 is( $our_branch_rules->count, 0, "We deleted 8 rules");
557 $schema->storage->txn_rollback;
560 subtest 'get_onshelfholds_policy() tests' => sub {
564 $schema->storage->txn_begin;
566 my $item = $builder->build_sample_item();
568 my $circ_rules = Koha::CirculationRules->new;
570 $circ_rules->search({ rule_name => 'onshelfholds' })->delete;
572 $circ_rules->set_rule(
577 rule_name => 'onshelfholds',
582 is( $circ_rules->get_onshelfholds_policy({ item => $item }), 1, 'If rule_value is set on a matching rule, return it' );
583 # Delete the rule (i.e. get_effective_rule returns undef)
585 is( $circ_rules->get_onshelfholds_policy({ item => $item }), 0, 'If no matching rule, fallback to 0' );
587 $schema->storage->txn_rollback;
590 subtest 'get_effective_daysmode' => sub {
593 $schema->storage->txn_begin;
595 my $item_1 = $builder->build_sample_item();
596 my $item_2 = $builder->build_sample_item();
599 Koha::CirculationRules->search( { rule_name => 'daysmode' } )->delete;
601 # Default value 'Datedue' at pref level
602 t::lib::Mocks::mock_preference( 'useDaysMode', 'Datedue' );
605 Koha::CirculationRules->get_effective_daysmode(
607 categorycode => undef,
608 itemtype => $item_1->effective_itemtype,
613 'daysmode default to pref value if the rule does not exist'
616 Koha::CirculationRules->set_rule(
621 rule_name => 'daysmode',
622 rule_value => 'Calendar',
625 Koha::CirculationRules->set_rule(
629 itemtype => $item_1->effective_itemtype,
630 rule_name => 'daysmode',
631 rule_value => 'Days',
636 Koha::CirculationRules->get_effective_daysmode(
638 categorycode => undef,
639 itemtype => $item_1->effective_itemtype,
644 "daysmode for item_1 is the specific rule"
647 Koha::CirculationRules->get_effective_daysmode(
649 categorycode => undef,
650 itemtype => $item_2->effective_itemtype,
655 "daysmode for item_2 is the one defined for the default circ rule"
658 Koha::CirculationRules->set_rule(
662 itemtype => $item_2->effective_itemtype,
663 rule_name => 'daysmode',
669 Koha::CirculationRules->get_effective_daysmode(
671 categorycode => undef,
672 itemtype => $item_2->effective_itemtype,
677 'daysmode default to pref value if the rule exists but set to""'
680 $schema->storage->txn_rollback;
683 subtest 'get_lostreturn_policy() tests' => sub {
686 $schema->storage->txn_begin;
688 $schema->resultset('CirculationRule')->search()->delete;
690 my $default_rule_charge = $builder->build(
692 source => 'CirculationRule',
695 categorycode => undef,
697 rule_name => 'lostreturn',
698 rule_value => 'charge'
702 my $branchcode = $builder->build( { source => 'Branch' } )->{branchcode};
703 my $specific_rule_false = $builder->build(
705 source => 'CirculationRule',
707 branchcode => $branchcode,
708 categorycode => undef,
710 rule_name => 'lostreturn',
715 my $branchcode2 = $builder->build( { source => 'Branch' } )->{branchcode};
716 my $specific_rule_refund = $builder->build(
718 source => 'CirculationRule',
720 branchcode => $branchcode2,
721 categorycode => undef,
723 rule_name => 'lostreturn',
724 rule_value => 'refund'
728 my $branchcode3 = $builder->build( { source => 'Branch' } )->{branchcode};
729 my $specific_rule_restore = $builder->build(
731 source => 'CirculationRule',
733 branchcode => $branchcode3,
734 categorycode => undef,
736 rule_name => 'lostreturn',
737 rule_value => 'restore'
742 # Make sure we have an unused branchcode
743 my $branchcode4 = $builder->build( { source => 'Branch' } )->{branchcode};
744 my $specific_rule_dummy = $builder->build(
746 source => 'CirculationRule',
748 branchcode => $branchcode4,
749 categorycode => undef,
751 rule_name => 'lostreturn',
752 rule_value => 'refund'
756 my $branch_without_rule = $specific_rule_dummy->{ branchcode };
757 Koha::CirculationRules
760 branchcode => $branch_without_rule,
761 categorycode => undef,
763 rule_name => 'lostreturn',
764 rule_value => 'refund'
770 my $item = $builder->build_sample_item(
772 homebranch => $specific_rule_restore->{branchcode},
773 holdingbranch => $specific_rule_false->{branchcode}
777 return_branch => $specific_rule_refund->{ branchcode },
782 t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'CheckinLibrary' );
783 is( Koha::CirculationRules->get_lostreturn_policy( $params ),
784 'refund','Specific rule for checkin branch is applied (refund)');
786 t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'ItemHomeBranch' );
787 is( Koha::CirculationRules->get_lostreturn_policy( $params ),
788 'restore','Specific rule for home branch is applied (restore)');
790 t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'ItemHoldingBranch' );
791 is( Koha::CirculationRules->get_lostreturn_policy( $params ),
792 0,'Specific rule for holding branch is applied (false)');
795 t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'CheckinLibrary' );
796 $params->{return_branch} = $branch_without_rule;
797 is( Koha::CirculationRules->get_lostreturn_policy( $params ),
798 'charge','No rule for branch, global rule applied (charge)');
800 # Change the default value just to try
801 Koha::CirculationRules->search({ branchcode => undef, rule_name => 'lostreturn' })->next->rule_value(0)->store;
802 is( Koha::CirculationRules->get_lostreturn_policy( $params ),
803 0,'No rule for branch, global rule applied (false)');
805 # No default rule defined check
806 Koha::CirculationRules
810 categorycode => undef,
812 rule_name => 'lostreturn'
817 is( Koha::CirculationRules->get_lostreturn_policy( $params ),
818 'refund','No rule for branch, no default rule, fallback default (refund)');
820 # Fallback to ItemHoldBranch if CheckinLibrary is undefined
821 $params->{return_branch} = undef;
822 is( Koha::CirculationRules->get_lostreturn_policy( $params ),
823 'restore','return_branch undefined, fallback to ItemHomeBranch rule (restore)');
825 $schema->storage->txn_rollback;
828 subtest 'get_processingreturn_policy() tests' => sub {
831 $schema->storage->txn_begin;
833 $schema->resultset('CirculationRule')->search()->delete;
835 my $default_rule_charge = $builder->build(
837 source => 'CirculationRule',
840 categorycode => undef,
842 rule_name => 'processingreturn',
843 rule_value => 'charge'
847 my $branchcode = $builder->build( { source => 'Branch' } )->{branchcode};
848 my $specific_rule_false = $builder->build(
850 source => 'CirculationRule',
852 branchcode => $branchcode,
853 categorycode => undef,
855 rule_name => 'processingreturn',
860 my $branchcode2 = $builder->build( { source => 'Branch' } )->{branchcode};
861 my $specific_rule_refund = $builder->build(
863 source => 'CirculationRule',
865 branchcode => $branchcode2,
866 categorycode => undef,
868 rule_name => 'processingreturn',
869 rule_value => 'refund'
873 my $branchcode3 = $builder->build( { source => 'Branch' } )->{branchcode};
874 my $specific_rule_restore = $builder->build(
876 source => 'CirculationRule',
878 branchcode => $branchcode3,
879 categorycode => undef,
881 rule_name => 'processingreturn',
882 rule_value => 'restore'
887 # Make sure we have an unused branchcode
888 my $branchcode4 = $builder->build( { source => 'Branch' } )->{branchcode};
889 my $specific_rule_dummy = $builder->build(
891 source => 'CirculationRule',
893 branchcode => $branchcode4,
894 categorycode => undef,
896 rule_name => 'processingreturn',
897 rule_value => 'refund'
901 my $branch_without_rule = $specific_rule_dummy->{ branchcode };
902 Koha::CirculationRules
905 branchcode => $branch_without_rule,
906 categorycode => undef,
908 rule_name => 'processingreturn',
909 rule_value => 'refund'
915 my $item = $builder->build_sample_item(
917 homebranch => $specific_rule_restore->{branchcode},
918 holdingbranch => $specific_rule_false->{branchcode}
922 return_branch => $specific_rule_refund->{ branchcode },
927 t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'CheckinLibrary' );
928 is( Koha::CirculationRules->get_processingreturn_policy( $params ),
929 'refund','Specific rule for checkin branch is applied (refund)');
931 t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'ItemHomeBranch' );
932 is( Koha::CirculationRules->get_processingreturn_policy( $params ),
933 'restore','Specific rule for home branch is applied (restore)');
935 t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'ItemHoldingBranch' );
936 is( Koha::CirculationRules->get_processingreturn_policy( $params ),
937 0,'Specific rule for holding branch is applied (false)');
940 t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'CheckinLibrary' );
941 $params->{return_branch} = $branch_without_rule;
942 is( Koha::CirculationRules->get_processingreturn_policy( $params ),
943 'charge','No rule for branch, global rule applied (charge)');
945 # Change the default value just to try
946 Koha::CirculationRules->search({ branchcode => undef, rule_name => 'processingreturn' })->next->rule_value(0)->store;
947 is( Koha::CirculationRules->get_processingreturn_policy( $params ),
948 0,'No rule for branch, global rule applied (false)');
950 # No default rule defined check
951 Koha::CirculationRules
955 categorycode => undef,
957 rule_name => 'processingreturn'
962 is( Koha::CirculationRules->get_processingreturn_policy( $params ),
963 'refund','No rule for branch, no default rule, fallback default (refund)');
965 # Fallback to ItemHoldBranch if CheckinLibrary is undefined
966 $params->{return_branch} = undef;
967 is( Koha::CirculationRules->get_processingreturn_policy( $params ),
968 'restore','return_branch undefined, fallback to ItemHomeBranch rule (restore)');
970 $schema->storage->txn_rollback;
974 my ( $rule, $expected, $message ) = @_;
976 ok( $rule, $message ) ?
977 cmp_methods( $rule, [ %$expected ], $message ) :
981 sub _prepare_tests_for_rule_scope_combinations {
982 my ( $scope, $rule_name ) = @_;
984 # Here we create a combinations of 1s and 0s the following way
995 # (the number of columns equals to the amount of rule scopes)
996 # The ... symbolizes possible future scopes.
998 # - 0 equals to circulation rule scope with any value (aka. *)
999 # - 1 equals to circulation rule scope exact value, e.g.
1000 # "CPL" (for branchcode).
1002 # The order is the same as the weight of scopes when sorting circulation
1003 # rules. So the first column of numbers is the scope with most weight.
1004 # This is defined by C<$order> which will be assigned next.
1006 # We must maintain the order in order to keep the test valid. This should be
1007 # equal to Koha/CirculationRules.pm "order_by" of C<get_effective_rule> sub.
1008 # Let's explicitly define the order and fail test if we are missing a scope:
1009 my $order = [ 'branchcode', 'categorycode', 'itemtype' ];
1010 is( join(", ", sort keys %$scope),
1011 join(", ", sort @$order), 'Missing a scope!' ) if keys %$scope ne scalar @$order;
1014 foreach my $value ( glob( "{0,1}" x keys %$scope || 1 ) ) {
1015 my $test = { %$scope };
1016 for ( my $i=0; $i < keys %$scope; $i++ ) {
1017 $test->{$order->[$i]} = '*' unless substr( $value, $i, 1 );
1022 return \@tests, $order;