Lines 17-25
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 49; |
20 |
use Test::More tests => 51; |
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 74-82
$dbh->do(q|DELETE FROM statistics|);
Link Here
|
74 |
# Generate sample datas |
73 |
# Generate sample datas |
75 |
my $itemtype = $builder->build( |
74 |
my $itemtype = $builder->build( |
76 |
{ source => 'Itemtype', |
75 |
{ source => 'Itemtype', |
77 |
value => { notforloan => undef, rentalcharge => 0 } |
76 |
value => { notforloan => undef, rentalcharge => 0, updatenotforloan => 1 } |
|
|
77 |
} |
78 |
)->{itemtype}; |
79 |
my $itemtype2 = $builder->build( |
80 |
{ source => 'Itemtype', |
81 |
value => { notforloan => undef, updatenotforloan => 0 } |
78 |
} |
82 |
} |
79 |
)->{itemtype}; |
83 |
)->{itemtype}; |
|
|
84 |
|
80 |
my $branchcode_1 = $builder->build({ source => 'Branch' })->{branchcode}; |
85 |
my $branchcode_1 = $builder->build({ source => 'Branch' })->{branchcode}; |
81 |
my $branchcode_2 = $builder->build({ source => 'Branch' })->{branchcode}; |
86 |
my $branchcode_2 = $builder->build({ source => 'Branch' })->{branchcode}; |
82 |
my $branchcode_3 = $builder->build({ source => 'Branch' })->{branchcode}; |
87 |
my $branchcode_3 = $builder->build({ source => 'Branch' })->{branchcode}; |
Lines 123-132
my $daysago10 = output_pref(
Link Here
|
123 |
|
128 |
|
124 |
# Add biblio and item |
129 |
# Add biblio and item |
125 |
my $record = MARC::Record->new(); |
130 |
my $record = MARC::Record->new(); |
|
|
131 |
my $record2 = MARC::Record->new(); |
126 |
$record->append_fields( |
132 |
$record->append_fields( |
|
|
133 |
MARC::Field->new( '942', '0', '0', c => $itemtype ), |
134 |
MARC::Field->new( '952', '0', '0', a => $branchcode_1 ) ); |
135 |
|
136 |
$record2->append_fields( |
137 |
MARC::Field->new( '942', '0', '0', c => $itemtype2 ), |
127 |
MARC::Field->new( '952', '0', '0', a => $branchcode_1 ) ); |
138 |
MARC::Field->new( '952', '0', '0', a => $branchcode_1 ) ); |
128 |
|
139 |
|
129 |
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( $record, '' ); |
140 |
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( $record, '' ); |
|
|
141 |
my ( $biblionumber2, $biblioitemnumber2 ) = C4::Biblio::AddBiblio( $record2, '' ); |
130 |
|
142 |
|
131 |
my $barcode_1 = 'barcode_1'; |
143 |
my $barcode_1 = 'barcode_1'; |
132 |
my $barcode_2 = 'barcode_2'; |
144 |
my $barcode_2 = 'barcode_2'; |
Lines 385-391
my $itemnumber = Koha::Item->new(
Link Here
|
385 |
homebranch => $branchcode_1, |
397 |
homebranch => $branchcode_1, |
386 |
holdingbranch => $branchcode_1, |
398 |
holdingbranch => $branchcode_1, |
387 |
notforloan => 1, |
399 |
notforloan => 1, |
388 |
itype => $itemtype |
400 |
itype => $itemtype, |
|
|
401 |
biblioitemnumber => $biblioitemnumber |
389 |
}, |
402 |
}, |
390 |
)->store->itemnumber; |
403 |
)->store->itemnumber; |
391 |
|
404 |
|
Lines 397-412
AddReturn( 'barcode_3', $branchcode_1 );
Link Here
|
397 |
my $item = Koha::Items->find( $itemnumber ); |
410 |
my $item = Koha::Items->find( $itemnumber ); |
398 |
ok( $item->notforloan eq 1, 'UpdateNotForLoanStatusOnCheckin does not modify value when not enabled' ); |
411 |
ok( $item->notforloan eq 1, 'UpdateNotForLoanStatusOnCheckin does not modify value when not enabled' ); |
399 |
|
412 |
|
400 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '1: 9' ); |
413 |
my $updatenotforloanstatusoncheckin = " |
|
|
414 |
$itemtype:\n |
415 |
1: 9 |
416 |
"; |
417 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', $updatenotforloanstatusoncheckin ); |
401 |
AddReturn( 'barcode_3', $branchcode_1 ); |
418 |
AddReturn( 'barcode_3', $branchcode_1 ); |
402 |
$item = Koha::Items->find( $itemnumber ); |
419 |
$item = Koha::Items->find( $itemnumber ); |
403 |
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin updates notforloan value from 1 to 9 with setting "1: 9"} ); |
420 |
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin updates notforloan value from 1 to 9 with setting "1: 9" for the item type returned} ); |
404 |
my $log_count_after = $schema->resultset('ActionLog')->search({module => 'CATALOGUING'})->count(); |
421 |
my $log_count_after = $schema->resultset('ActionLog')->search({module => 'CATALOGUING'})->count(); |
405 |
is($log_count_before, $log_count_after, "Change from UpdateNotForLoanStatusOnCheckin is not logged"); |
422 |
is($log_count_before, $log_count_after, "Change from UpdateNotForLoanStatusOnCheckin is not logged"); |
406 |
|
423 |
|
407 |
AddReturn( 'barcode_3', $branchcode_1 ); |
424 |
AddReturn( 'barcode_3', $branchcode_1 ); |
408 |
$item = Koha::Items->find( $itemnumber ); |
425 |
$item = Koha::Items->find( $itemnumber ); |
409 |
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9"} ); |
426 |
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9" for the item type returned} ); |
|
|
427 |
|
428 |
# Change the returning item to an item type without a rule |
429 |
Koha::Items->find( $itemnumber )->itype( $itemtype2 )->store; |
430 |
Koha::Items->find( $itemnumber )->notforloan( 1 )->store; |
431 |
AddReturn( 'barcode_3', $branchcode_1 ); |
432 |
$item = Koha::Items->find( $itemnumber ); |
433 |
ok( $item->notforloan eq 1, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 1 when there is no setting for the items' itemtype} ); |
410 |
|
434 |
|
411 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '1: ONLYMESSAGE' ); |
435 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '1: ONLYMESSAGE' ); |
412 |
$item->notforloan(1)->store; |
436 |
$item->notforloan(1)->store; |
Lines 496-501
is( $item3->location, 'CART', q{UpdateItemLocationOnCheckin updates location val
Link Here
|
496 |
|
520 |
|
497 |
|
521 |
|
498 |
# Bug 14640 - Cancel the hold on checking out if asked |
522 |
# Bug 14640 - Cancel the hold on checking out if asked |
|
|
523 |
Koha::Items->find({ barcode => $barcode_1 })->notforloan('0')->store; |
499 |
my $reserve_id = AddReserve( |
524 |
my $reserve_id = AddReserve( |
500 |
{ |
525 |
{ |
501 |
branchcode => $branchcode_1, |
526 |
branchcode => $branchcode_1, |
502 |
- |
|
|