|
Lines 466-472
subtest '1 BranchBorrowerCircRule exist: 1 CO allowed, 1 OSCO allowed' => sub {
Link Here
|
| 466 |
}; |
466 |
}; |
| 467 |
|
467 |
|
| 468 |
subtest 'General vs specific rules limit quantity correctly' => sub { |
468 |
subtest 'General vs specific rules limit quantity correctly' => sub { |
| 469 |
plan tests => 9; |
469 |
plan tests => 10; |
| 470 |
|
470 |
|
| 471 |
t::lib::Mocks::mock_preference('CircControl', 'ItemHomeLibrary'); |
471 |
t::lib::Mocks::mock_preference('CircControl', 'ItemHomeLibrary'); |
| 472 |
my $branch = $builder->build({source => 'Branch',}); |
472 |
my $branch = $builder->build({source => 'Branch',}); |
|
Lines 516-522
subtest 'General vs specific rules limit quantity correctly' => sub {
Link Here
|
| 516 |
); |
516 |
); |
| 517 |
|
517 |
|
| 518 |
# Create an item |
518 |
# Create an item |
| 519 |
my $item = $builder->build_sample_item({ |
519 |
my $issue_item = $builder->build_sample_item({ |
| 520 |
itype => $itemtype->{itemtype} |
520 |
itype => $itemtype->{itemtype} |
| 521 |
}); |
521 |
}); |
| 522 |
my $branch_item = $builder->build_sample_item({ |
522 |
my $branch_item = $builder->build_sample_item({ |
|
Lines 527-533
subtest 'General vs specific rules limit quantity correctly' => sub {
Link Here
|
| 527 |
|
527 |
|
| 528 |
|
528 |
|
| 529 |
t::lib::Mocks::mock_userenv({ branchcode => $branch->{branchcode} }); |
529 |
t::lib::Mocks::mock_userenv({ branchcode => $branch->{branchcode} }); |
| 530 |
my $issue = C4::Circulation::AddIssue( $patron, $item->barcode, dt_from_string() ); |
530 |
my $issue = C4::Circulation::AddIssue( $patron, $issue_item->barcode, dt_from_string() ); |
| 531 |
# We checkout one item |
531 |
# We checkout one item |
| 532 |
is_deeply( |
532 |
is_deeply( |
| 533 |
C4::Circulation::TooMany( $patron, $branch_item->biblionumber, $branch_item->unblessed ), |
533 |
C4::Circulation::TooMany( $patron, $branch_item->biblionumber, $branch_item->unblessed ), |
|
Lines 536-544
subtest 'General vs specific rules limit quantity correctly' => sub {
Link Here
|
| 536 |
count => 1, |
536 |
count => 1, |
| 537 |
max_allowed => 1, |
537 |
max_allowed => 1, |
| 538 |
}, |
538 |
}, |
| 539 |
'We are only allowed one, and we have one' |
539 |
'We are only allowed one, and we have one (itemtype on item)' |
| 540 |
); |
540 |
); |
| 541 |
|
541 |
|
|
|
542 |
# Check itemtype on biblio level |
| 543 |
t::lib::Mocks::mock_preference('item-level_itypes', 0); |
| 544 |
$issue_item->biblio->biblioitem->itemtype($itemtype->{itemtype})->store; |
| 545 |
$branch_item->biblio->biblioitem->itemtype($itemtype->{itemtype})->store; |
| 546 |
# We checkout one item |
| 547 |
is_deeply( |
| 548 |
C4::Circulation::TooMany( $patron, $branch_item->biblionumber, $branch_item->unblessed ), |
| 549 |
{ |
| 550 |
reason => 'TOO_MANY_CHECKOUTS', |
| 551 |
count => 1, |
| 552 |
max_allowed => 1, |
| 553 |
}, |
| 554 |
'We are only allowed one, and we have one (itemtype on biblioitem)' |
| 555 |
); |
| 556 |
t::lib::Mocks::mock_preference('item-level_itypes', 1); |
| 542 |
|
557 |
|
| 543 |
# Set a branch specific rule |
558 |
# Set a branch specific rule |
| 544 |
Koha::CirculationRules->set_rules( |
559 |
Koha::CirculationRules->set_rules( |
| 545 |
- |
|
|