X-Git-Url: http://git.equinoxoli.org/?p=koha-equinox.git;a=blobdiff_plain;f=t%2Fdb_dependent%2FKoha%2FIssuingRules.t;fp=t%2Fdb_dependent%2FKoha%2FIssuingRules.t;h=31abe27c4cec7e5df3ba07f8e93a68af1553a6a9;hp=4d37fcfebc4a1c660b1fb19e4daf01fe4acad060;hb=5b61408eb736d8a795eaeb9f7b44583d79e8b66a;hpb=bbf209133e0503df28ab1ae004e560f42425918b diff --git a/t/db_dependent/Koha/IssuingRules.t b/t/db_dependent/Koha/IssuingRules.t index 4d37fcf..31abe27 100644 --- a/t/db_dependent/Koha/IssuingRules.t +++ b/t/db_dependent/Koha/IssuingRules.t @@ -36,7 +36,7 @@ $schema->storage->txn_begin; my $builder = t::lib::TestBuilder->new; subtest 'get_effective_issuing_rule' => sub { - plan tests => 3; + plan tests => 2; my $categorycode = $builder->build({ source => 'Category' })->{'categorycode'}; my $itemtype = $builder->build({ source => 'Itemtype' })->{'itemtype'}; @@ -94,301 +94,6 @@ subtest 'get_effective_issuing_rule' => sub { ); }; - subtest 'Get effective issuing rule in correct order' => sub { - plan tests => 26; - - my $rule; - Koha::CirculationRules->delete; - is(Koha::CirculationRules->search->count, 0, 'There are no issuing rules.'); - $rule = Koha::CirculationRules->get_effective_rule({ - branchcode => $branchcode, - categorycode => $categorycode, - itemtype => $itemtype, - rule_name => 'fine', - }); - is($rule, undef, 'When I attempt to get effective issuing rule, then undef' - .' is returned.'); - - # undef, undef, undef => 5 - ok(Koha::CirculationRule->new({ - branchcode => undef, - categorycode => undef, - itemtype => undef, - rule_name => 'fine', - rule_value => 5, - })->store, 'Given I added an issuing rule branchcode => undef, categorycode => undef, itemtype => undef,'); - $rule = Koha::CirculationRules->get_effective_rule({ - branchcode => $branchcode, - categorycode => $categorycode, - itemtype => $itemtype, - rule_name => 'fine', - }); - _is_row_match( - $rule, - { - branchcode => undef, - categorycode => undef, - itemtype => undef, - rule_name => 'fine', - rule_value => 5, - }, - 'When I attempt to get effective issuing rule,' - .' then the above one is returned.' - ); - - # undef, undef, undef => 5 - # undef, undef, $itemtype => 7 - ok( - Koha::CirculationRule->new( - { - branchcode => undef, - categorycode => undef, - itemtype => $itemtype, - rule_name => 'fine', - rule_value => 7, - } - )->store, - "Given I added an issuing rule branchcode => undef, categorycode => undef, itemtype => $itemtype," - ); - $rule = Koha::CirculationRules->get_effective_rule({ - branchcode => $branchcode, - categorycode => $categorycode, - itemtype => $itemtype, - rule_name => 'fine', - }); - _is_row_match( - $rule, - { - branchcode => undef, - categorycode => undef, - itemtype => $itemtype, - rule_name => 'fine', - rule_value => 7, - }, - 'When I attempt to get effective issuing rule,' - .' then the above one is returned.' - ); - - # undef, undef, undef => 5 - # undef, undef, $itemtype => 7 - # undef, $categorycode, undef => 9 - ok( - Koha::CirculationRule->new( - { - branchcode => undef, - categorycode => $categorycode, - itemtype => undef, - rule_name => 'fine', - rule_value => 9, - } - )->store, - "Given I added an issuing rule branchcode => undef, categorycode => $categorycode, itemtype => undef," - ); - $rule = Koha::CirculationRules->get_effective_rule({ - branchcode => $branchcode, - categorycode => $categorycode, - itemtype => $itemtype, - rule_name => 'fine', - }); - _is_row_match( - $rule, - { - branchcode => undef, - categorycode => $categorycode, - itemtype => undef, - rule_name => 'fine', - rule_value => 9, - }, - 'When I attempt to get effective issuing rule,' - .' then the above one is returned.' - ); - - # undef, undef, undef => 5 - # undef, undef, $itemtype => 7 - # undef, $categorycode, undef => 9 - # undef, $categorycode, $itemtype => 11 - ok( - Koha::CirculationRule->new( - { - branchcode => undef, - categorycode => $categorycode, - itemtype => $itemtype, - rule_name => 'fine', - rule_value => 11, - } - )->store, - "Given I added an issuing rule branchcode => undef, categorycode => $categorycode, itemtype => $itemtype," - ); - $rule = Koha::CirculationRules->get_effective_rule({ - branchcode => $branchcode, - categorycode => $categorycode, - itemtype => $itemtype, - rule_name => 'fine', - }); - _is_row_match( - $rule, - { - branchcode => undef, - categorycode => $categorycode, - itemtype => $itemtype, - rule_name => 'fine', - rule_value => 11, - }, - 'When I attempt to get effective issuing rule,' - .' then the above one is returned.' - ); - - # undef, undef, undef => 5 - # undef, undef, $itemtype => 7 - # undef, $categorycode, undef => 9 - # undef, $categorycode, $itemtype => 11 - # $branchcode, undef, undef => 13 - ok( - Koha::CirculationRule->new( - { - branchcode => $branchcode, - categorycode => undef, - itemtype => undef, - rule_name => 'fine', - rule_value => 13, - } - )->store, - "Given I added an issuing rule branchcode => $branchcode, categorycode => undef, itemtype => undef," - ); - $rule = Koha::CirculationRules->get_effective_rule({ - branchcode => $branchcode, - categorycode => $categorycode, - itemtype => $itemtype, - rule_name => 'fine', - }); - _is_row_match( - $rule, - { - branchcode => $branchcode, - categorycode => undef, - itemtype => undef, - rule_name => 'fine', - rule_value => 13, - }, - 'When I attempt to get effective issuing rule,' - .' then the above one is returned.' - ); - - # undef, undef, undef => 5 - # undef, undef, $itemtype => 7 - # undef, $categorycode, undef => 9 - # undef, $categorycode, $itemtype => 11 - # $branchcode, undef, undef => 13 - # $branchcode, undef, $itemtype => 15 - ok( - Koha::CirculationRule->new( - { - branchcode => $branchcode, - categorycode => undef, - itemtype => $itemtype, - rule_name => 'fine', - rule_value => 15, - } - )->store, - "Given I added an issuing rule branchcode => $branchcode, categorycode => undef, itemtype => $itemtype," - ); - $rule = Koha::CirculationRules->get_effective_rule({ - branchcode => $branchcode, - categorycode => $categorycode, - itemtype => $itemtype, - rule_name => 'fine', - }); - _is_row_match( - $rule, - { - branchcode => $branchcode, - categorycode => undef, - itemtype => $itemtype, - rule_name => 'fine', - rule_value => 15, - }, - 'When I attempt to get effective issuing rule,' - .' then the above one is returned.' - ); - - # undef, undef, undef => 5 - # undef, undef, $itemtype => 7 - # undef, $categorycode, undef => 9 - # undef, $categorycode, $itemtype => 11 - # $branchcode, undef, undef => 13 - # $branchcode, undef, $itemtype => 15 - # $branchcode, $categorycode, undef => 17 - ok( - Koha::CirculationRule->new( - { - branchcode => $branchcode, - categorycode => $categorycode, - itemtype => undef, - rule_name => 'fine', - rule_value => 17, - } - )->store, - "Given I added an issuing rule branchcode => $branchcode, categorycode => $categorycode, itemtype => undef," - ); - $rule = Koha::CirculationRules->get_effective_rule({ - branchcode => $branchcode, - categorycode => $categorycode, - itemtype => $itemtype, - rule_name => 'fine', - }); - _is_row_match( - $rule, - { - branchcode => $branchcode, - categorycode => $categorycode, - itemtype => undef, - rule_name => 'fine', - rule_value => 17, - }, - 'When I attempt to get effective issuing rule,' - .' then the above one is returned.' - ); - - # undef, undef, undef => 5 - # undef, undef, $itemtype => 7 - # undef, $categorycode, undef => 9 - # undef, $categorycode, $itemtype => 11 - # $branchcode, undef, undef => 13 - # $branchcode, undef, $itemtype => 15 - # $branchcode, $categorycode, undef => 17 - # $branchcode, $categorycode, $itemtype => 19 - ok( - Koha::CirculationRule->new( - { - branchcode => $branchcode, - categorycode => $categorycode, - itemtype => $itemtype, - rule_name => 'fine', - rule_value => 19, - } - )->store, - "Given I added an issuing rule branchcode => $branchcode, categorycode => $categorycode, itemtype => $itemtype," - ); - $rule = Koha::CirculationRules->get_effective_rule({ - branchcode => $branchcode, - categorycode => $categorycode, - itemtype => $itemtype, - rule_name => 'fine', - }); - _is_row_match( - $rule, - { - branchcode => $branchcode, - categorycode => $categorycode, - itemtype => $itemtype, - rule_name => 'fine', - rule_value => 19, - }, - 'When I attempt to get effective issuing rule,' - .' then the above one is returned.' - ); - }; - subtest 'Performance' => sub { plan tests => 4;