|
Lines 19-25
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 1; |
22 |
use Test::More tests => 2; |
| 23 |
use Test::Exception; |
23 |
use Test::Exception; |
| 24 |
|
24 |
|
| 25 |
use Koha::CirculationRules; |
25 |
use Koha::CirculationRules; |
|
Lines 28-40
use Koha::Database;
Link Here
|
| 28 |
use t::lib::TestBuilder; |
28 |
use t::lib::TestBuilder; |
| 29 |
|
29 |
|
| 30 |
my $schema = Koha::Database->new->schema; |
30 |
my $schema = Koha::Database->new->schema; |
| 31 |
$schema->storage->txn_begin; |
|
|
| 32 |
|
| 33 |
my $builder = t::lib::TestBuilder->new; |
31 |
my $builder = t::lib::TestBuilder->new; |
| 34 |
|
32 |
|
| 35 |
subtest 'set_rule + get_effective_rule' => sub { |
33 |
subtest 'set_rule + get_effective_rule' => sub { |
| 36 |
plan tests => 14; |
34 |
plan tests => 14; |
| 37 |
|
35 |
|
|
|
36 |
$schema->storage->txn_begin; |
| 37 |
|
| 38 |
my $categorycode = $builder->build_object( { class => 'Koha::Patron::Categories' } )->categorycode; |
38 |
my $categorycode = $builder->build_object( { class => 'Koha::Patron::Categories' } )->categorycode; |
| 39 |
my $itemtype = $builder->build_object( { class => 'Koha::ItemTypes' } )->itemtype; |
39 |
my $itemtype = $builder->build_object( { class => 'Koha::ItemTypes' } )->itemtype; |
| 40 |
my $branchcode = $builder->build_object( { class => 'Koha::Libraries' } )->branchcode; |
40 |
my $branchcode = $builder->build_object( { class => 'Koha::Libraries' } )->branchcode; |
|
Lines 250-256
subtest 'set_rule + get_effective_rule' => sub {
Link Here
|
| 250 |
$our_branch_rules->delete; |
250 |
$our_branch_rules->delete; |
| 251 |
is( $our_branch_rules->count, 0, "We deleted 8 rules"); |
251 |
is( $our_branch_rules->count, 0, "We deleted 8 rules"); |
| 252 |
|
252 |
|
| 253 |
|
253 |
$schema->storage->txn_rollback; |
| 254 |
}; |
254 |
}; |
| 255 |
|
255 |
|
| 256 |
$schema->storage->txn_rollback; |
256 |
subtest 'get_onshelfholds_policy() tests' => sub { |
|
|
257 |
|
| 258 |
plan tests => 2; |
| 259 |
|
| 260 |
$schema->storage->txn_begin; |
| 261 |
|
| 262 |
my $item = $builder->build_sample_item(); |
| 263 |
|
| 264 |
my $circ_rules = Koha::CirculationRules->new; |
| 265 |
# Cleanup |
| 266 |
$circ_rules->search({ rule_name => 'onshelfholds' })->delete; |
| 267 |
|
| 268 |
$circ_rules->set_rule( |
| 269 |
{ |
| 270 |
branchcode => '*', |
| 271 |
categorycode => '*', |
| 272 |
itemtype => '*', |
| 273 |
rule_name => 'onshelfholds', |
| 274 |
rule_value => 1, |
| 275 |
} |
| 276 |
); |
| 277 |
|
| 278 |
is( $circ_rules->get_onshelfholds_policy({ item => $item }), 1, 'If rule_value is set on a matching rule, return it' ); |
| 279 |
# Delete the rule (i.e. get_effective_rule returns undef) |
| 280 |
$circ_rules->delete; |
| 281 |
is( $circ_rules->get_onshelfholds_policy({ item => $item }), 0, 'If no matching rule, fallback to 0' ); |
| 282 |
|
| 283 |
$schema->storage->txn_rollback; |
| 284 |
}; |
| 257 |
- |
|
|