View | Details | Raw Unified | Return to bug 25560
Collapse All | Expand All

(-)a/t/db_dependent/Circulation/issue.t (-8 / +32 lines)
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 => 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 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 403-418 AddReturn( 'barcode_3', $branchcode_1 ); Link Here
403
my $item = Koha::Items->find( $itemnumber );
416
my $item = Koha::Items->find( $itemnumber );
404
ok( $item->notforloan eq 1, 'UpdateNotForLoanStatusOnCheckin does not modify value when not enabled' );
417
ok( $item->notforloan eq 1, 'UpdateNotForLoanStatusOnCheckin does not modify value when not enabled' );
405
418
406
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '1: 9' );
419
my $updatenotforloanstatusoncheckin = "
420
$itemtype:\n
421
  1: 9
422
";
423
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', $updatenotforloanstatusoncheckin );
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 updates notforloan value from 1 to 9 with setting "1: 9"} );
426
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();
427
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");
428
is($log_count_before, $log_count_after, "Change from UpdateNotForLoanStatusOnCheckin is not logged");
412
429
413
AddReturn( 'barcode_3', $branchcode_1 );
430
AddReturn( 'barcode_3', $branchcode_1 );
414
$item = Koha::Items->find( $itemnumber );
431
$item = Koha::Items->find( $itemnumber );
415
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9"} );
432
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9" for the item type returned} );
433
434
# Change the returning item to an item type without a rule
435
Koha::Items->find( $itemnumber )->itype( $itemtype2 )->store;
436
Koha::Items->find( $itemnumber )->notforloan( 1 )->store;
437
AddReturn( 'barcode_3', $branchcode_1 );
438
$item = Koha::Items->find( $itemnumber );
439
ok( $item->notforloan eq 1, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 1 when there is no setting for the items' itemtype} );
416
440
417
my $itemnumber2 = Koha::Item->new(
441
my $itemnumber2 = Koha::Item->new(
418
    {
442
    {
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
- 

Return to bug 25560