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 => 52; |
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 } |
79 |
} |
78 |
} |
80 |
)->{itemtype}; |
79 |
)->{itemtype}; |
|
|
80 |
my $itemtype2 = $builder->build( |
81 |
{ source => 'Itemtype', |
82 |
value => { notforloan => undef, updatenotforloan => 0 } |
83 |
} |
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-400
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 |
|
|
|
411 |
# item-level_itypes syspref is set to 'specific item' |
412 |
t::lib::Mocks::mock_preference( 'item-level_itypes', '1' ); |
413 |
|
398 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', q{} ); |
414 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', q{} ); |
399 |
t::lib::Mocks::mock_preference( 'CataloguingLog', 1 ); |
415 |
t::lib::Mocks::mock_preference( 'CataloguingLog', 1 ); |
400 |
my $log_count_before = $schema->resultset('ActionLog')->search({module => 'CATALOGUING'})->count(); |
416 |
my $log_count_before = $schema->resultset('ActionLog')->search({module => 'CATALOGUING'})->count(); |
Lines 403-418
AddReturn( 'barcode_3', $branchcode_1 );
Link Here
|
403 |
my $item = Koha::Items->find( $itemnumber ); |
419 |
my $item = Koha::Items->find( $itemnumber ); |
404 |
ok( $item->notforloan eq 1, 'UpdateNotForLoanStatusOnCheckin does not modify value when not enabled' ); |
420 |
ok( $item->notforloan eq 1, 'UpdateNotForLoanStatusOnCheckin does not modify value when not enabled' ); |
405 |
|
421 |
|
406 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '1: 9' ); |
422 |
my $updatenotforloanstatusoncheckin = " |
|
|
423 |
$itemtype:\n |
424 |
1: 9 |
425 |
"; |
426 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', $updatenotforloanstatusoncheckin ); |
407 |
AddReturn( 'barcode_3', $branchcode_1 ); |
427 |
AddReturn( 'barcode_3', $branchcode_1 ); |
408 |
$item = Koha::Items->find( $itemnumber ); |
428 |
$item = Koha::Items->find( $itemnumber ); |
409 |
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin updates notforloan value from 1 to 9 with setting "1: 9"} ); |
429 |
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin updates notforloan value from 1 to 9 with setting "1: 9" for the item type returned} ); |
410 |
my $log_count_after = $schema->resultset('ActionLog')->search({module => 'CATALOGUING'})->count(); |
430 |
my $log_count_after = $schema->resultset('ActionLog')->search({module => 'CATALOGUING'})->count(); |
411 |
is($log_count_before, $log_count_after, "Change from UpdateNotForLoanStatusOnCheckin is not logged"); |
431 |
is($log_count_before, $log_count_after, "Change from UpdateNotForLoanStatusOnCheckin is not logged"); |
412 |
|
432 |
|
413 |
AddReturn( 'barcode_3', $branchcode_1 ); |
433 |
AddReturn( 'barcode_3', $branchcode_1 ); |
414 |
$item = Koha::Items->find( $itemnumber ); |
434 |
$item = Koha::Items->find( $itemnumber ); |
415 |
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9"} ); |
435 |
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9" for the item type returned} ); |
|
|
436 |
|
437 |
# Change the returning item to an item type without a rule |
438 |
Koha::Items->find( $itemnumber )->itype( $itemtype2 )->store; |
439 |
Koha::Items->find( $itemnumber )->notforloan( 1 )->store; |
440 |
AddReturn( 'barcode_3', $branchcode_1 ); |
441 |
$item = Koha::Items->find( $itemnumber ); |
442 |
ok( $item->notforloan eq 1, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 1 when there is no setting for the items' itemtype} ); |
443 |
|
444 |
# Test UpdateNotForLoanStatusOnCheckin with different biblioitems.itemtype and items.itype values |
445 |
|
446 |
# item-level_itypes syspref is set to 'bibliographic record' |
447 |
t::lib::Mocks::mock_preference( 'item-level_itypes', '0' ); |
448 |
|
449 |
Koha::Items->find( $itemnumber )->biblioitemnumber( $biblioitemnumber2 )->store; |
450 |
Koha::Items->find( $itemnumber )->itype($itemtype)->store; |
451 |
AddReturn( 'barcode_3', $branchcode_1 ); |
452 |
$item = Koha::Items->find( $itemnumber ); |
453 |
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin updates notforloan value from 1 to 9 when the authoritative item type has a setting "1: 9" for that item type} ); |
416 |
|
454 |
|
417 |
my $itemnumber2 = Koha::Item->new( |
455 |
my $itemnumber2 = Koha::Item->new( |
418 |
{ |
456 |
{ |
Lines 496-501
is( $item3->location, 'CART', q{UpdateItemLocationOnCheckin updates location val
Link Here
|
496 |
|
534 |
|
497 |
|
535 |
|
498 |
# Bug 14640 - Cancel the hold on checking out if asked |
536 |
# Bug 14640 - Cancel the hold on checking out if asked |
|
|
537 |
Koha::Items->find({ barcode => $barcode_1 })->notforloan('0')->store; |
499 |
my $reserve_id = AddReserve( |
538 |
my $reserve_id = AddReserve( |
500 |
{ |
539 |
{ |
501 |
branchcode => $branchcode_1, |
540 |
branchcode => $branchcode_1, |
502 |
- |
|
|