Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 67; |
20 |
use Test::More tests => 65; |
21 |
use DateTime::Duration; |
21 |
use DateTime::Duration; |
22 |
|
22 |
|
23 |
use t::lib::Mocks; |
23 |
use t::lib::Mocks; |
Lines 496-530
is(
Link Here
|
496 |
# |
496 |
# |
497 |
############################################## |
497 |
############################################## |
498 |
|
498 |
|
499 |
my $itemnumber4 = Koha::Item->new( |
499 |
subtest 'AddReturn: Update notforloanstatus according to UpdateNotForLoanStatusOnCheckout' => sub { |
500 |
{ |
500 |
plan tests => 5; |
501 |
biblionumber => $biblionumber, |
|
|
502 |
barcode => 'barcode_6', |
503 |
itemcallnumber => 'callnumber6', |
504 |
homebranch => $branchcode_1, |
505 |
holdingbranch => $branchcode_1, |
506 |
notforloan => -1, |
507 |
itype => $itemtype, |
508 |
location => 'loc1' |
509 |
}, |
510 |
)->store->itemnumber; |
511 |
|
512 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckout', q{} ); |
513 |
AddIssue( $patron_2, 'barcode_6', dt_from_string ); |
514 |
$item = Koha::Items->find( $itemnumber4 ); |
515 |
ok( $item->notforloan eq -1, 'UpdateNotForLoanStatusOnCheckout does not modify value when not enabled' ); |
516 |
|
517 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckout', '-1: 0' ); |
518 |
AddReturn( 'barcode_6', $branchcode_1 ); |
519 |
my $test = AddIssue( $patron_2, 'barcode_6', dt_from_string ); |
520 |
$item = Koha::Items->find( $itemnumber4 ); |
521 |
ok( $item->notforloan eq 0, q{UpdateNotForLoanStatusOnCheckout updates notforloan value from -1 to 0 with setting "-1: 0"} ); |
522 |
|
523 |
AddIssue( $patron_2, 'barcode_6', dt_from_string ); |
524 |
AddReturn( 'barcode_6', $branchcode_1 ); |
525 |
$item = Koha::Items->find( $itemnumber4 ); |
526 |
ok( $item->notforloan eq 0, q{UpdateNotForLoanStatusOnCheckout does not update notforloan value from 0 with setting "-1: 0"} ); |
527 |
|
501 |
|
|
|
502 |
my $itemnumber4 = Koha::Item->new( |
503 |
{ |
504 |
biblionumber => $biblionumber, |
505 |
barcode => 'barcode_6', |
506 |
itemcallnumber => 'callnumber6', |
507 |
homebranch => $branchcode_1, |
508 |
holdingbranch => $branchcode_1, |
509 |
notforloan => -1, |
510 |
itype => $itemtype, |
511 |
location => 'loc1' |
512 |
}, |
513 |
)->store->itemnumber; |
514 |
|
515 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckout', q{} ); |
516 |
AddIssue( $patron_2, 'barcode_6', dt_from_string ); |
517 |
$item = Koha::Items->find($itemnumber4); |
518 |
ok( $item->notforloan eq -1, 'UpdateNotForLoanStatusOnCheckout does not modify value when not enabled' ); |
519 |
AddReturn( 'barcode_6', $branchcode_1 ); |
520 |
|
521 |
t::lib::Mocks::mock_preference( |
522 |
'UpdateNotForLoanStatusOnCheckout', q{ _ALL_: |
523 |
-1: 0 |
524 |
} |
525 |
); |
526 |
$item->notforloan(-1)->store; |
527 |
my $test = AddIssue( $patron_2, 'barcode_6', dt_from_string ); |
528 |
$item = Koha::Items->find($itemnumber4); |
529 |
ok( |
530 |
$item->notforloan eq 0, |
531 |
q{UpdateNotForLoanStatusOnCheckout updates notforloan value from -1 to 0 with setting "_ALL_: -1: 0"} |
532 |
); |
533 |
AddReturn( 'barcode_6', $branchcode_1 ); |
534 |
|
535 |
$item->notforloan(1)->store; |
536 |
AddIssue( $patron_2, 'barcode_6', dt_from_string ); |
537 |
$item = Koha::Items->find($itemnumber4); |
538 |
ok( |
539 |
$item->notforloan eq 1, |
540 |
q{UpdateNotForLoanStatusOnCheckout does not update notforloan value from 1 with setting "_ALL_: -1: 0"} |
541 |
); |
542 |
AddReturn( 'barcode_6', $branchcode_1 ); |
543 |
|
544 |
t::lib::Mocks::mock_preference( |
545 |
'UpdateNotForLoanStatusOnCheckout', q{ |
546 |
_ALL_: |
547 |
-1: 0 |
548 |
} . $itemtype . q{: |
549 |
-1: 1 |
550 |
} |
551 |
); |
552 |
|
553 |
$item->notforloan(-1)->store; |
554 |
AddIssue( $patron_2, 'barcode_6', dt_from_string ); |
555 |
$item = Koha::Items->find($itemnumber4); |
556 |
ok( $item->notforloan eq 1, q{UpdateNotForLoanStatusOnCheckout uses the most specific rule to update notforloan } ); |
557 |
AddReturn( 'barcode_6', $branchcode_1 ); |
558 |
|
559 |
t::lib::Mocks::mock_preference( |
560 |
'UpdateNotForLoanStatusOnCheckout', q{ |
561 |
_ALL_: |
562 |
-1: 0 |
563 |
NOT_} . $itemtype . q{: |
564 |
-1: 1 |
565 |
} |
566 |
); |
567 |
|
568 |
$item->notforloan(-1)->store; |
569 |
AddIssue( $patron_2, 'barcode_6', dt_from_string ); |
570 |
$item = Koha::Items->find($itemnumber4); |
571 |
ok( |
572 |
$item->notforloan eq 0, |
573 |
q{UpdateNotForLoanStatusOnCheckout uses the default rule (_ALL_) if no rule matches the itype} |
574 |
); |
575 |
AddReturn( 'barcode_6', $branchcode_1 ); |
576 |
|
577 |
$item->delete; |
578 |
}; |
528 |
|
579 |
|
529 |
########################################## |
580 |
########################################## |
530 |
# |
581 |
# |
531 |
- |
|
|