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

(-)a/t/db_dependent/Circulation/Returns.t (-48 / +7 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 5;
20
use Test::More tests => 6;
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Warn;
22
use Test::Warn;
23
23
Lines 60-106 my $rule = Koha::IssuingRule->new( Link Here
60
);
60
);
61
$rule->store();
61
$rule->store();
62
62
63
subtest "InProcessingToShelvingCart tests" => sub {
64
65
    plan tests => 2;
66
67
    $branch = $builder->build({ source => 'Branch' })->{ branchcode };
68
    my $permanent_location = 'TEST';
69
    my $location           = 'PROC';
70
71
    # Create a biblio record with biblio-level itemtype
72
    my $record = MARC::Record->new();
73
    my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, '' );
74
    my $built_item = $builder->build({
75
        source => 'Item',
76
        value  => {
77
            biblionumber  => $biblionumber,
78
            homebranch    => $branch,
79
            holdingbranch => $branch,
80
            location      => $location,
81
            permanent_location => $permanent_location
82
        }
83
    });
84
    my $barcode = $built_item->{ barcode };
85
    my $itemnumber = $built_item->{ itemnumber };
86
    my $item;
87
88
    t::lib::Mocks::mock_preference( "InProcessingToShelvingCart", 1 );
89
    AddReturn( $barcode, $branch );
90
    $item = GetItem( $itemnumber );
91
    is( $item->{location}, 'CART',
92
        "InProcessingToShelvingCart functions as intended" );
93
94
    $item->{location} = $location;
95
    ModItem( $item, undef, $itemnumber );
96
97
    t::lib::Mocks::mock_preference( "InProcessingToShelvingCart", 0 );
98
    AddReturn( $barcode, $branch );
99
    $item = GetItem( $itemnumber );
100
    is( $item->{location}, $permanent_location,
101
        "InProcessingToShelvingCart functions as intended" );
102
};
103
104
63
105
subtest "AddReturn logging on statistics table (item-level_itypes=1)" => sub {
64
subtest "AddReturn logging on statistics table (item-level_itypes=1)" => sub {
106
65
Lines 175-187 subtest "AddReturn logging on statistics table (item-level_itypes=1)" => sub { Link Here
175
134
176
    is( $stat->itemtype, $ilevel_itemtype,
135
    is( $stat->itemtype, $ilevel_itemtype,
177
        "item-level itype recorded on statistics for return");
136
        "item-level itype recorded on statistics for return");
178
    warning_like { AddIssue( $borrower, $item_without_itemtype->{ barcode } ) }
137
    warnings_like { AddIssue( $borrower, $item_without_itemtype->{ barcode } ) }
179
                 [qr/^item-level_itypes set but no itemtype set for item/,
138
                 [qr/^item-level_itypes set but no itemtype set for item/,qr/^item-level_itypes set but no itemtype set for item/],
180
                 qr/^item-level_itypes set but no itemtype set for item/],
181
                 'Item without itemtype set raises warning on AddIssue';
139
                 'Item without itemtype set raises warning on AddIssue';
182
    warning_like { AddReturn( $item_without_itemtype->{ barcode }, $branch ) }
140
    warnings_like { AddReturn( $item_without_itemtype->{ barcode }, $branch ) }
183
                 qr/^item-level_itypes set but no itemtype set for item/,
141
                [qr/^item-level_itypes set but no itemtype set for item/,qr/^item-level_itypes set but no itemtype set for item/],
184
                 'Item without itemtype set raises warning on AddReturn';
142
                 'Item without itemtype set raises warnings on AddReturn';
185
    # Test biblio-level itemtype was recorded on the 'statistics' table
143
    # Test biblio-level itemtype was recorded on the 'statistics' table
186
    $stat = $schema->resultset('Statistic')->search({
144
    $stat = $schema->resultset('Statistic')->search({
187
        branch     => $branch,
145
        branch     => $branch,
Lines 331-336 subtest 'Handle ids duplication' => sub { Link Here
331
289
332
    is( Koha::Checkouts->find( $issue_id )->issue_id, $issue_id, 'The issues entry should not have been removed' );
290
    is( Koha::Checkouts->find( $issue_id )->issue_id, $issue_id, 'The issues entry should not have been removed' );
333
};
291
};
292
$schema->storage->txn_rollback;
334
293
335
subtest 'BlockReturnOfLostItems' => sub {
294
subtest 'BlockReturnOfLostItems' => sub {
336
    plan tests => 3;
295
    plan tests => 3;
(-)a/t/db_dependent/Circulation/issue.t (-1 / +53 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 31;
20
use Test::More tests => 43;
21
use DateTime::Duration;
21
use DateTime::Duration;
22
22
23
use t::lib::Mocks;
23
use t::lib::Mocks;
Lines 368-373 AddReturn( 'barcode_3', $branchcode_1 ); Link Here
368
$item = GetItem( $itemnumber );
368
$item = GetItem( $itemnumber );
369
ok( $item->{notforloan} eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9"} );
369
ok( $item->{notforloan} eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9"} );
370
370
371
my $itemnumber2;
372
($biblionumber, $biblioitemnumber, $itemnumber2) = C4::Items::AddItem(
373
    {
374
        barcode        => 'barcode_4',
375
        itemcallnumber => 'callnumber4',
376
        homebranch     => $branchcode_1,
377
        holdingbranch  => $branchcode_1,
378
        location => 'FIC',
379
        itype          => $itemtype
380
    },
381
    $biblionumber
382
);
383
384
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckin', q{} );
385
AddReturn( 'barcode_4', $branchcode_1 );
386
my $item2 = GetItem( $itemnumber2 );
387
ok( $item2->{location} eq 'FIC', 'UpdateItemLocationOnCheckin does not modify value when not enabled' );
388
389
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckin', 'FIC: GEN' );
390
AddReturn( 'barcode_4', $branchcode_1 );
391
$item2 = GetItem( $itemnumber2 );
392
ok( $item2->{location} eq 'GEN', q{UpdateItemLocationOnCheckin updates location value from 'FIC' to 'GEN' with setting "FIC: GEN"} );
393
ok( $item2->{permanent_location} eq 'GEN', q{UpdateItemLocationOnCheckin updates permanent_location value from 'FIC' to 'GEN' with setting "FIC: GEN"} );
394
AddReturn( 'barcode_4', $branchcode_1 );
395
$item2 = GetItem( $itemnumber2 );
396
ok( $item2->{location} eq 'GEN', q{UpdateItemLocationOnCheckin does not update location value from 'GEN' with setting "FIC: GEN"} );
397
398
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckin', '_ALL_: CART' );
399
AddReturn( 'barcode_4', $branchcode_1 );
400
$item2 = GetItem( $itemnumber2 );
401
ok( $item2->{location} eq 'CART', q{UpdateItemLocationOnCheckin updates location value from 'GEN' with setting "_ALL_: CART"} );
402
ok( $item2->{permanent_location} eq 'GEN', q{UpdateItemLocationOnCheckin does not update permanent_location value from 'GEN' with setting "_ALL_: CART"} );
403
AddIssue( $borrower_1, 'barcode_4', $daysago10,0, $today, '' );
404
$item2 = GetItem( $itemnumber2 );
405
ok( $item2->{location} eq 'GEN', q{Location updates from 'CART' to permanent location on issue} );
406
407
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckin', "GEN: _BLANK_\n_BLANK_: PROC\nPROC: _PERM_" );
408
AddReturn( 'barcode_4', $branchcode_1 );
409
$item2 = GetItem( $itemnumber2 );
410
ok( $item2->{location} eq '', q{UpdateItemLocationOnCheckin updates location value from 'GEN' to '' with setting "GEN: _BLANK_"} );
411
AddReturn( 'barcode_4', $branchcode_1 );
412
$item2 = GetItem( $itemnumber2 );
413
ok( $item2->{location} eq 'PROC' , q{UpdateItemLocationOnCheckin updates location value from '' to 'PROC' with setting "_BLANK_: PROC"} );
414
ok( $item2->{permanent_location} eq '' , q{UpdateItemLocationOnCheckin does not update permanent_location value from '' to 'PROC' with setting "_BLANK_: PROC"} );
415
AddReturn( 'barcode_4', $branchcode_1 );
416
$item2 = GetItem( $itemnumber2 );
417
ok( $item2->{location} eq '' , q{UpdateItemLocationOnCheckin updates location value from 'PROC' to '' with setting "PROC: _PERM_" } );
418
ok( $item2->{permanent_location} eq '' , q{UpdateItemLocationOnCheckin does not update permanent_location from '' with setting "PROC: _PERM_" } );
419
420
421
422
371
# Bug 14640 - Cancel the hold on checking out if asked
423
# Bug 14640 - Cancel the hold on checking out if asked
372
my $reserve_id = AddReserve($branchcode_1, $borrower_id1, $biblionumber,
424
my $reserve_id = AddReserve($branchcode_1, $borrower_id1, $biblionumber,
373
    undef,  1, undef, undef, "a note", "a title", undef, '');
425
    undef,  1, undef, undef, "a note", "a title", undef, '');
(-)a/t/db_dependent/UsageStats.t (-3 lines)
Lines 397-403 sub mocking_systempreferences_to_a_set_value { Link Here
397
        CircControl
397
        CircControl
398
        HomeOrHoldingBranch
398
        HomeOrHoldingBranch
399
        HomeOrHoldingBranchReturn
399
        HomeOrHoldingBranchReturn
400
        InProcessingToShelvingCart
401
        IssueLostItem
400
        IssueLostItem
402
        IssuingInProcess
401
        IssuingInProcess
403
        ManInvInNoissuesCharge
402
        ManInvInNoissuesCharge
Lines 406-412 sub mocking_systempreferences_to_a_set_value { Link Here
406
        RenewalSendNotice
405
        RenewalSendNotice
407
        RentalsInNoissuesCharge
406
        RentalsInNoissuesCharge
408
        ReturnBeforeExpiry
407
        ReturnBeforeExpiry
409
        ReturnToShelvingCart
410
        TransfersMaxDaysWarning
408
        TransfersMaxDaysWarning
411
        UseBranchTransferLimits
409
        UseBranchTransferLimits
412
        useDaysMode
410
        useDaysMode
413
- 

Return to bug 14576