Lines 18-24
Link Here
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::NoWarnings; |
20 |
use Test::NoWarnings; |
21 |
use Test::More tests => 68; |
21 |
use Test::More tests => 66; |
22 |
use DateTime::Duration; |
22 |
use DateTime::Duration; |
23 |
|
23 |
|
24 |
use t::lib::Mocks; |
24 |
use t::lib::Mocks; |
Lines 519-558
is(
Link Here
|
519 |
# |
519 |
# |
520 |
############################################## |
520 |
############################################## |
521 |
|
521 |
|
522 |
my $itemnumber4 = Koha::Item->new( |
522 |
subtest 'AddReturn: Update notforloanstatus according to UpdateNotForLoanStatusOnCheckout' => sub { |
523 |
{ |
523 |
plan tests => 5; |
524 |
biblionumber => $biblionumber, |
|
|
525 |
barcode => 'barcode_6', |
526 |
itemcallnumber => 'callnumber6', |
527 |
homebranch => $branchcode_1, |
528 |
holdingbranch => $branchcode_1, |
529 |
notforloan => -1, |
530 |
itype => $itemtype, |
531 |
location => 'loc1' |
532 |
}, |
533 |
)->store->itemnumber; |
534 |
|
535 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckout', q{} ); |
536 |
AddIssue( $patron_2, 'barcode_6', dt_from_string ); |
537 |
$item = Koha::Items->find($itemnumber4); |
538 |
ok( $item->notforloan eq -1, 'UpdateNotForLoanStatusOnCheckout does not modify value when not enabled' ); |
539 |
|
524 |
|
540 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckout', '-1: 0' ); |
525 |
my $itemnumber4 = Koha::Item->new( |
541 |
AddReturn( 'barcode_6', $branchcode_1 ); |
526 |
{ |
542 |
my $test = AddIssue( $patron_2, 'barcode_6', dt_from_string ); |
527 |
biblionumber => $biblionumber, |
543 |
$item = Koha::Items->find($itemnumber4); |
528 |
barcode => 'barcode_6', |
544 |
ok( |
529 |
itemcallnumber => 'callnumber6', |
545 |
$item->notforloan eq 0, |
530 |
homebranch => $branchcode_1, |
546 |
q{UpdateNotForLoanStatusOnCheckout updates notforloan value from -1 to 0 with setting "-1: 0"} |
531 |
holdingbranch => $branchcode_1, |
547 |
); |
532 |
notforloan => -1, |
548 |
|
533 |
itype => $itemtype, |
549 |
AddIssue( $patron_2, 'barcode_6', dt_from_string ); |
534 |
location => 'loc1' |
550 |
AddReturn( 'barcode_6', $branchcode_1 ); |
535 |
}, |
551 |
$item = Koha::Items->find($itemnumber4); |
536 |
)->store->itemnumber; |
552 |
ok( |
537 |
|
553 |
$item->notforloan eq 0, |
538 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckout', q{} ); |
554 |
q{UpdateNotForLoanStatusOnCheckout does not update notforloan value from 0 with setting "-1: 0"} |
539 |
AddIssue( $patron_2, 'barcode_6', dt_from_string ); |
555 |
); |
540 |
$item = Koha::Items->find($itemnumber4); |
|
|
541 |
ok( $item->notforloan eq -1, 'UpdateNotForLoanStatusOnCheckout does not modify value when not enabled' ); |
542 |
AddReturn( 'barcode_6', $branchcode_1 ); |
543 |
|
544 |
t::lib::Mocks::mock_preference( |
545 |
'UpdateNotForLoanStatusOnCheckout', q{ _ALL_: |
546 |
-1: 0 |
547 |
} |
548 |
); |
549 |
$item->notforloan(-1)->store; |
550 |
my $test = AddIssue( $patron_2, 'barcode_6', dt_from_string ); |
551 |
$item = Koha::Items->find($itemnumber4); |
552 |
ok( |
553 |
$item->notforloan eq 0, |
554 |
q{UpdateNotForLoanStatusOnCheckout updates notforloan value from -1 to 0 with setting "_ALL_: -1: 0"} |
555 |
); |
556 |
AddReturn( 'barcode_6', $branchcode_1 ); |
557 |
|
558 |
$item->notforloan(1)->store; |
559 |
AddIssue( $patron_2, 'barcode_6', dt_from_string ); |
560 |
$item = Koha::Items->find($itemnumber4); |
561 |
ok( |
562 |
$item->notforloan eq 1, |
563 |
q{UpdateNotForLoanStatusOnCheckout does not update notforloan value from 1 with setting "_ALL_: -1: 0"} |
564 |
); |
565 |
AddReturn( 'barcode_6', $branchcode_1 ); |
566 |
|
567 |
t::lib::Mocks::mock_preference( |
568 |
'UpdateNotForLoanStatusOnCheckout', q{ |
569 |
_ALL_: |
570 |
-1: 0 |
571 |
} . $itemtype . q{: |
572 |
-1: 1 |
573 |
} |
574 |
); |
575 |
|
576 |
$item->notforloan(-1)->store; |
577 |
AddIssue( $patron_2, 'barcode_6', dt_from_string ); |
578 |
$item = Koha::Items->find($itemnumber4); |
579 |
ok( $item->notforloan eq 1, q{UpdateNotForLoanStatusOnCheckout uses the most specific rule to update notforloan } ); |
580 |
AddReturn( 'barcode_6', $branchcode_1 ); |
581 |
|
582 |
t::lib::Mocks::mock_preference( |
583 |
'UpdateNotForLoanStatusOnCheckout', q{ |
584 |
_ALL_: |
585 |
-1: 0 |
586 |
NOT_} . $itemtype . q{: |
587 |
-1: 1 |
588 |
} |
589 |
); |
590 |
|
591 |
$item->notforloan(-1)->store; |
592 |
AddIssue( $patron_2, 'barcode_6', dt_from_string ); |
593 |
$item = Koha::Items->find($itemnumber4); |
594 |
ok( |
595 |
$item->notforloan eq 0, |
596 |
q{UpdateNotForLoanStatusOnCheckout uses the default rule (_ALL_) if no rule matches the itype} |
597 |
); |
598 |
AddReturn( 'barcode_6', $branchcode_1 ); |
599 |
|
600 |
$item->delete; |
601 |
}; |
556 |
|
602 |
|
557 |
########################################## |
603 |
########################################## |
558 |
# |
604 |
# |
559 |
- |
|
|