|
Lines 19-25
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 2; |
22 |
use Test::More tests => 3; |
| 23 |
use Test::Exception; |
23 |
use Test::Exception; |
| 24 |
|
24 |
|
| 25 |
use Koha::CirculationRules; |
25 |
use Koha::CirculationRules; |
|
Lines 282-284
subtest 'get_onshelfholds_policy() tests' => sub {
Link Here
|
| 282 |
|
282 |
|
| 283 |
$schema->storage->txn_rollback; |
283 |
$schema->storage->txn_rollback; |
| 284 |
}; |
284 |
}; |
| 285 |
- |
285 |
|
|
|
286 |
subtest 'set_rules() tests' => sub { |
| 287 |
plan tests => 1; |
| 288 |
|
| 289 |
subtest 'scope validation' => sub { |
| 290 |
plan tests => 6; |
| 291 |
|
| 292 |
$schema->storage->txn_begin; |
| 293 |
|
| 294 |
my $categorycode = $builder->build_object( { |
| 295 |
class => 'Koha::Patron::Categories' } )->categorycode; |
| 296 |
my $itemtype = $builder->build_object( { |
| 297 |
class => 'Koha::ItemTypes' } )->itemtype; |
| 298 |
my $branchcode = $builder->build_object( { |
| 299 |
class => 'Koha::Libraries' } )->branchcode; |
| 300 |
|
| 301 |
my $rule; |
| 302 |
Koha::CirculationRules->delete; |
| 303 |
|
| 304 |
is( scalar @{Koha::CirculationRules->set_rules( { |
| 305 |
branchcode => $branchcode, |
| 306 |
categorycode => $categorycode, |
| 307 |
itemtype => $itemtype, |
| 308 |
rules => { |
| 309 |
refund => 1, |
| 310 |
patron_maxissueqty => 2, |
| 311 |
holdallowed => 3, |
| 312 |
article_requests => 4, |
| 313 |
maxissueqty => 5, |
| 314 |
} |
| 315 |
} )}, 5, 'All rules added' ); |
| 316 |
|
| 317 |
is( Koha::CirculationRules->get_effective_rule( { |
| 318 |
branchcode => $branchcode, |
| 319 |
rule_name => 'refund' |
| 320 |
} )->rule_value, 1, 'Found rule refund' ); |
| 321 |
|
| 322 |
is( Koha::CirculationRules->get_effective_rule( { |
| 323 |
branchcode => $branchcode, |
| 324 |
categorycode => $categorycode, |
| 325 |
rule_name => 'patron_maxissueqty' |
| 326 |
} )->rule_value, 2, 'Found rule patron_maxissueqty' ); |
| 327 |
|
| 328 |
is( Koha::CirculationRules->get_effective_rule( { |
| 329 |
branchcode => $branchcode, |
| 330 |
itemtype => $itemtype, |
| 331 |
rule_name => 'holdallowed' |
| 332 |
} )->rule_value, 3, 'Found rule holdallowed' ); |
| 333 |
|
| 334 |
is( Koha::CirculationRules->get_effective_rule( { |
| 335 |
branchcode => $branchcode, |
| 336 |
categorycode => $categorycode, |
| 337 |
itemtype => $itemtype, |
| 338 |
rule_name => 'article_requests' |
| 339 |
} )->rule_value, 4, 'Found rule article_requests' ); |
| 340 |
|
| 341 |
is( Koha::CirculationRules->get_effective_rule( { |
| 342 |
branchcode => $branchcode, |
| 343 |
categorycode => $categorycode, |
| 344 |
itemtype => $itemtype, |
| 345 |
rule_name => 'maxissueqty' |
| 346 |
} )->rule_value, 5, 'Found rule maxissueqty' ); |
| 347 |
|
| 348 |
$schema->storage->txn_rollback; |
| 349 |
}; |
| 350 |
}; |