Lines 17-25
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 50; |
20 |
use Test::More tests => 61; |
21 |
use DateTime::Duration; |
21 |
use DateTime::Duration; |
22 |
|
|
|
23 |
use t::lib::Mocks; |
22 |
use t::lib::Mocks; |
24 |
use t::lib::TestBuilder; |
23 |
use t::lib::TestBuilder; |
25 |
|
24 |
|
Lines 75-83
$dbh->do(q|DELETE FROM statistics|);
Link Here
|
75 |
# Generate sample datas |
74 |
# Generate sample datas |
76 |
my $itemtype = $builder->build( |
75 |
my $itemtype = $builder->build( |
77 |
{ source => 'Itemtype', |
76 |
{ source => 'Itemtype', |
78 |
value => { notforloan => undef, rentalcharge => 0 } |
77 |
value => { notforloan => undef, rentalcharge => 0, updatenotforloan => 1 } |
|
|
78 |
} |
79 |
)->{itemtype}; |
80 |
my $itemtype2 = $builder->build( |
81 |
{ source => 'Itemtype', |
82 |
value => { notforloan => undef, updatenotforloan => 0 } |
79 |
} |
83 |
} |
80 |
)->{itemtype}; |
84 |
)->{itemtype}; |
|
|
85 |
|
81 |
my $branchcode_1 = $builder->build({ source => 'Branch' })->{branchcode}; |
86 |
my $branchcode_1 = $builder->build({ source => 'Branch' })->{branchcode}; |
82 |
my $branchcode_2 = $builder->build({ source => 'Branch' })->{branchcode}; |
87 |
my $branchcode_2 = $builder->build({ source => 'Branch' })->{branchcode}; |
83 |
my $branchcode_3 = $builder->build({ source => 'Branch' })->{branchcode}; |
88 |
my $branchcode_3 = $builder->build({ source => 'Branch' })->{branchcode}; |
Lines 124-133
my $daysago10 = output_pref(
Link Here
|
124 |
|
129 |
|
125 |
# Add biblio and item |
130 |
# Add biblio and item |
126 |
my $record = MARC::Record->new(); |
131 |
my $record = MARC::Record->new(); |
|
|
132 |
my $record2 = MARC::Record->new(); |
127 |
$record->append_fields( |
133 |
$record->append_fields( |
|
|
134 |
MARC::Field->new( '942', '0', '0', c => $itemtype ), |
135 |
MARC::Field->new( '952', '0', '0', a => $branchcode_1 ) ); |
136 |
|
137 |
$record2->append_fields( |
138 |
MARC::Field->new( '942', '0', '0', c => $itemtype2 ), |
128 |
MARC::Field->new( '952', '0', '0', a => $branchcode_1 ) ); |
139 |
MARC::Field->new( '952', '0', '0', a => $branchcode_1 ) ); |
129 |
|
140 |
|
130 |
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( $record, '' ); |
141 |
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( $record, '' ); |
|
|
142 |
my ( $biblionumber2, $biblioitemnumber2 ) = C4::Biblio::AddBiblio( $record2, '' ); |
131 |
|
143 |
|
132 |
my $barcode_1 = 'barcode_1'; |
144 |
my $barcode_1 = 'barcode_1'; |
133 |
my $barcode_2 = 'barcode_2'; |
145 |
my $barcode_2 = 'barcode_2'; |
Lines 391-397
my $itemnumber = Koha::Item->new(
Link Here
|
391 |
homebranch => $branchcode_1, |
403 |
homebranch => $branchcode_1, |
392 |
holdingbranch => $branchcode_1, |
404 |
holdingbranch => $branchcode_1, |
393 |
notforloan => 1, |
405 |
notforloan => 1, |
394 |
itype => $itemtype |
406 |
itype => $itemtype, |
|
|
407 |
biblioitemnumber => $biblioitemnumber |
395 |
}, |
408 |
}, |
396 |
)->store->itemnumber; |
409 |
)->store->itemnumber; |
397 |
|
410 |
|
Lines 414-419
AddReturn( 'barcode_3', $branchcode_1 );
Link Here
|
414 |
$item = Koha::Items->find( $itemnumber ); |
427 |
$item = Koha::Items->find( $itemnumber ); |
415 |
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9"} ); |
428 |
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9"} ); |
416 |
|
429 |
|
|
|
430 |
# Bug 25560: Exclude itemtypes from UpdateNotForLoanStatusOnCheckin syspref |
431 |
|
432 |
# item-level_itypes syspref is set to 'Specific item' |
433 |
t::lib::Mocks::mock_preference( 'item-level_itypes', '1' ); |
434 |
|
435 |
# Set biblioitems.itemtype to an itemtype with updatenotforloan = 0 |
436 |
Koha::Items->find( $itemnumber )->biblioitemnumber($biblioitemnumber2)->store; |
437 |
ok( Koha::ItemTypes->find(Koha::Biblioitems->find({ biblioitemnumber => $biblioitemnumber2 })->itemtype)->updatenotforloan eq 0, q{Biblio-level itemtype has a updatenotforloan set to 0} ); |
438 |
|
439 |
# Keep items.itype on an itemtype with updatenotforloan = 1 |
440 |
ok( Koha::ItemTypes->find(Koha::Items->find($itemnumber)->itype)->updatenotforloan eq 1, q{item level itemtype has a updatenotforloan set to 1}); |
441 |
|
442 |
# items.notforloan status should change as the effective itemtype (item-level itype) |
443 |
# does allow notforloan status to be updated on checkin |
444 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '9: 1'); |
445 |
AddReturn( 'barcode_3', $branchcode_1 ); |
446 |
$item = Koha::Items->find( $itemnumber ); |
447 |
ok( $item->notforloan eq 1, q{UpdateNotForLoanStatusOnCheckin does update the notforloan value when ithe effective itemtype (specific item) has an enabled updatenotforloan flag} ); |
448 |
|
449 |
# Set biblioitems.itemtype to an itemtype with updatenotforloan = 1 |
450 |
Koha::Items->find( $itemnumber )->biblioitemnumber($biblioitemnumber)->store; |
451 |
ok( Koha::ItemTypes->find(Koha::Biblioitems->find({ biblioitemnumber => $biblioitemnumber })->itemtype)->updatenotforloan eq 1, q{Biblio-level itemtype has a updatenotforloan set to 1 }); |
452 |
|
453 |
# Set items.itype to an itemtype with updatenotforloanstatus = 0 |
454 |
Koha::Items->find( $itemnumber )->itype($itemtype2)->store; |
455 |
ok( Koha::ItemTypes->find(Koha::Items->find($itemnumber)->itype)->updatenotforloan eq 0, q{item level itemtype has an updatenotforloan set to 0 }); |
456 |
|
457 |
# items.notforloan status shouldn't change as the effective itemtype (item-level itype) |
458 |
# does not allow notforloan status to be updated on checkin |
459 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '1: 9'); |
460 |
AddReturn( 'barcode_3', $branchcode_1 ); |
461 |
$item = Koha::Items->find( $itemnumber ); |
462 |
ok( $item->notforloan eq 1, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value when th effective item type (specific item) has a disabled updatenotforloan flag} ); |
463 |
|
464 |
# item-level_itypes syspref is set to 'bibliographic record' |
465 |
t::lib::Mocks::mock_preference( 'item-level_itypes', '0' ); |
466 |
|
467 |
# Check items.itype is still an itemtype with updatenotforloan = 0 |
468 |
ok( Koha::ItemTypes->find(Koha::Items->find($itemnumber)->itype)->updatenotforloan eq 0, q{item level itype has a updatenotforloanstatuscheckin set to 0}); |
469 |
|
470 |
# items.notforloan status should change as the effective itemtype (biblio-level itemtype) |
471 |
# does allow notforloan status to be updated on checkin |
472 |
AddReturn( 'barcode_3', $branchcode_1 ); |
473 |
$item = Koha::Items->find( $itemnumber ); |
474 |
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin updates notforloan value when the effective item type (bibliographic record) has an enabled updatenotforloan flag} ); |
475 |
|
476 |
# Set biblioitems.itemtype to an itemtype with updatenotforloan = 0 |
477 |
Koha::Items->find( $itemnumber )->biblioitemnumber($biblioitemnumber2)->store; |
478 |
ok( Koha::ItemTypes->find(Koha::Biblioitems->find({ biblioitemnumber => $biblioitemnumber2 })->itemtype)->updatenotforloan eq 0, q{Biblio-level itemtype has a updatenotforloan set to 0 }); |
479 |
|
480 |
# Set items.itype to an itemtype with updatenotforloan = 1 |
481 |
Koha::Items->find( $itemnumber )->itype($itemtype)->store; |
482 |
ok( Koha::ItemTypes->find(Koha::Items->find($itemnumber)->itype)->updatenotforloan eq 1, q{item level itype has an updatenotforloan set to 1}); |
483 |
|
484 |
# items.notforloan status shouldn't change as the effective itemtype (biblio-level itemtype) |
485 |
# doesn't allow notforloan status to be updated at checkin |
486 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '9: 1'); |
487 |
AddReturn( 'barcode_3', $branchcode_1 ); |
488 |
$item = Koha::Items->find( $itemnumber ); |
489 |
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloanvalue when the effective itemtype (bibliographic record) has a disabled updatenotforloan flag} ); |
490 |
|
417 |
my $itemnumber2 = Koha::Item->new( |
491 |
my $itemnumber2 = Koha::Item->new( |
418 |
{ |
492 |
{ |
419 |
biblionumber => $biblionumber, |
493 |
biblionumber => $biblionumber, |
Lines 496-501
is( $item3->location, 'CART', q{UpdateItemLocationOnCheckin updates location val
Link Here
|
496 |
|
570 |
|
497 |
|
571 |
|
498 |
# Bug 14640 - Cancel the hold on checking out if asked |
572 |
# Bug 14640 - Cancel the hold on checking out if asked |
|
|
573 |
Koha::Items->find({ barcode => $barcode_1 })->notforloan('0')->store; |
499 |
my $reserve_id = AddReserve( |
574 |
my $reserve_id = AddReserve( |
500 |
{ |
575 |
{ |
501 |
branchcode => $branchcode_1, |
576 |
branchcode => $branchcode_1, |