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

(-)a/t/db_dependent/Circulation/issue.t (-4 / +79 lines)
Lines 17-25 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 46;
20
use Test::More tests => 57;
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 76-84 $dbh->do(q|DELETE FROM statistics|); Link Here
76
# Generate sample datas
75
# Generate sample datas
77
my $itemtype = $builder->build(
76
my $itemtype = $builder->build(
78
    {   source => 'Itemtype',
77
    {   source => 'Itemtype',
79
        value  => { notforloan => undef, rentalcharge => 0 }
78
        value  => { notforloan => undef, rentalcharge => 0, updatenotforloanstatusoncheckin => 1 }
79
    }
80
)->{itemtype};
81
my $itemtype2 = $builder->build(
82
    {   source => 'Itemtype',
83
        value  => { notforloan => undef, updatenotforloanstatusoncheckin => 0 }
80
    }
84
    }
81
)->{itemtype};
85
)->{itemtype};
86
82
my $branchcode_1 = $builder->build({ source => 'Branch' })->{branchcode};
87
my $branchcode_1 = $builder->build({ source => 'Branch' })->{branchcode};
83
my $branchcode_2 = $builder->build({ source => 'Branch' })->{branchcode};
88
my $branchcode_2 = $builder->build({ source => 'Branch' })->{branchcode};
84
my $branchcode_3 = $builder->build({ source => 'Branch' })->{branchcode};
89
my $branchcode_3 = $builder->build({ source => 'Branch' })->{branchcode};
Lines 125-134 my $daysago10 = output_pref( Link Here
125
130
126
# Add biblio and item
131
# Add biblio and item
127
my $record = MARC::Record->new();
132
my $record = MARC::Record->new();
133
my $record2 = MARC::Record->new();
128
$record->append_fields(
134
$record->append_fields(
135
    MARC::Field->new( '942', '0', '0', c => $itemtype ),
136
    MARC::Field->new( '952', '0', '0', a => $branchcode_1 ) );
137
138
$record2->append_fields(
139
    MARC::Field->new( '942', '0', '0', c => $itemtype2 ),
129
    MARC::Field->new( '952', '0', '0', a => $branchcode_1 ) );
140
    MARC::Field->new( '952', '0', '0', a => $branchcode_1 ) );
130
141
131
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( $record, '' );
142
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( $record, '' );
143
my ( $biblionumber2, $biblioitemnumber2 ) = C4::Biblio::AddBiblio( $record2, '' );
132
144
133
my $barcode_1 = 'barcode_1';
145
my $barcode_1 = 'barcode_1';
134
my $barcode_2 = 'barcode_2';
146
my $barcode_2 = 'barcode_2';
Lines 395-401 my $itemnumber = Koha::Item->new( Link Here
395
        homebranch     => $branchcode_1,
407
        homebranch     => $branchcode_1,
396
        holdingbranch  => $branchcode_1,
408
        holdingbranch  => $branchcode_1,
397
        notforloan     => 1,
409
        notforloan     => 1,
398
        itype          => $itemtype
410
        itype          => $itemtype,
411
        biblioitemnumber => $biblioitemnumber
399
    },
412
    },
400
)->store->itemnumber;
413
)->store->itemnumber;
401
414
Lines 413-418 AddReturn( 'barcode_3', $branchcode_1 ); Link Here
413
$item = Koha::Items->find( $itemnumber );
426
$item = Koha::Items->find( $itemnumber );
414
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9"} );
427
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9"} );
415
428
429
# Bug 25560: Exclude itemtypes from UpdateNotForLoanStatusOnCheckin syspref
430
431
# item-level_itypes syspref is set to 'Specific item'
432
t::lib::Mocks::mock_preference( 'item-level_itypes', '1' );
433
434
# Set biblioitems.itemtype to an itemtype with updatenotforloanstatusoncheckin = 0
435
Koha::Items->find( $itemnumber )->biblioitemnumber($biblioitemnumber2)->store;
436
ok( Koha::ItemTypes->find(Koha::Biblioitems->find({ biblioitemnumber => $biblioitemnumber2 })->itemtype)->updatenotforloanstatusoncheckin eq 0, q{Biblio-level itemtype has a updatenotforloanstatusoncheckin set to 0} );
437
438
# Keep items.itype on an itemtype with updatenotforloanstatusoncheckin = 1
439
ok( Koha::ItemTypes->find(Koha::Items->find($itemnumber)->itype)->updatenotforloanstatusoncheckin eq 1, q{item level itemtype has a updatenotforloanstatusoncheckin set to 1});
440
441
# items.notforloan status should change as the effective itemtype (item-level itype)
442
# does allow notforloan status to be updated on checkin
443
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '9: 1');
444
AddReturn( 'barcode_3', $branchcode_1 );
445
$item = Koha::Items->find( $itemnumber );
446
ok( $item->notforloan eq 1, q{UpdateNotForLoanStatusOnCheckin does update the notforloan value when ithe effective itemtype (specific item) has an enabled updatenotforloanstatusoncheckin flag} );
447
448
# Set biblioitems.itemtype to an itemtype with updatenotforloanstatusoncheckin = 1
449
Koha::Items->find( $itemnumber )->biblioitemnumber($biblioitemnumber)->store;
450
ok( Koha::ItemTypes->find(Koha::Biblioitems->find({ biblioitemnumber => $biblioitemnumber })->itemtype)->updatenotforloanstatusoncheckin eq 1, q{Biblio-level itemtype has a updatenotforloanstatusoncheckin set to 1 });
451
452
# Set items.itype to an itemtype with updatenotforloanstatus = 0
453
Koha::Items->find( $itemnumber )->itype($itemtype2)->store;
454
ok( Koha::ItemTypes->find(Koha::Items->find($itemnumber)->itype)->updatenotforloanstatusoncheckin eq 0, q{item level itemtype has an updatenotforloanstatusoncheckin set to 0 });
455
456
# items.notforloan status shouldn't change as the effective itemtype (item-level itype)
457
# does not allow notforloan status to be updated on checkin
458
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '1: 9');
459
AddReturn( 'barcode_3', $branchcode_1 );
460
$item = Koha::Items->find( $itemnumber );
461
ok( $item->notforloan eq 1, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value when th effective item type (specific item) has a disabled updatenotforloanstatusoncheckin flag} );
462
463
# item-level_itypes syspref is set to 'bibliographic record'
464
t::lib::Mocks::mock_preference( 'item-level_itypes', '0' );
465
466
# Check items.itype is still an itemtype with updatenotforloanstatusoncheckin = 0
467
ok( Koha::ItemTypes->find(Koha::Items->find($itemnumber)->itype)->updatenotforloanstatusoncheckin eq 0, q{item level itype has a updatenotforloanstatuscheckin set to 0});
468
469
# items.notforloan status should change as the effective itemtype (biblio-level itemtype)
470
# does allow notforloan status to be updated on checkin
471
AddReturn( 'barcode_3', $branchcode_1 );
472
$item = Koha::Items->find( $itemnumber );
473
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin updates notforloan value when the effective item type (bibliographic record) has an enabled updatenotforloanstatusoncheckin flag} );
474
475
# Set biblioitems.itemtype to an itemtype with updatenotforloanstatusoncheckin = 0
476
Koha::Items->find( $itemnumber )->biblioitemnumber($biblioitemnumber2)->store;
477
ok( Koha::ItemTypes->find(Koha::Biblioitems->find({ biblioitemnumber => $biblioitemnumber2 })->itemtype)->updatenotforloanstatusoncheckin eq 0, q{Biblio-level itemtype has a updatenotforloanstatusoncheckin set to 0 });
478
479
# Set items.itype to an itemtype with updatenotforloanstatusoncheckin = 1
480
Koha::Items->find( $itemnumber )->itype($itemtype)->store;
481
ok( Koha::ItemTypes->find(Koha::Items->find($itemnumber)->itype)->updatenotforloanstatusoncheckin eq 1, q{item level itype has an updatenotforloanstatuconcheckin set to 1});
482
483
# items.notforloan status shouldn't change as the effective itemtype (biblio-level itemtype)
484
# doesn't allow notforloan status to be updated at checkin
485
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '9: 1');
486
AddReturn( 'barcode_3', $branchcode_1 );
487
$item = Koha::Items->find( $itemnumber );
488
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloanvalue when the effective itemtype (bibliographic record) has a disabled updatenotforloanstatusoncheckin flag} );
489
416
my $itemnumber2 = Koha::Item->new(
490
my $itemnumber2 = Koha::Item->new(
417
    {
491
    {
418
        biblionumber   => $biblionumber,
492
        biblionumber   => $biblionumber,
Lines 475-480 ok( $item2->permanent_location eq '' , q{UpdateItemLocationOnCheckin does not up Link Here
475
549
476
550
477
# Bug 14640 - Cancel the hold on checking out if asked
551
# Bug 14640 - Cancel the hold on checking out if asked
552
Koha::Items->find({ barcode => $barcode_1 })->notforloan('0')->store;
478
my $reserve_id = AddReserve(
553
my $reserve_id = AddReserve(
479
    {
554
    {
480
        branchcode     => $branchcode_1,
555
        branchcode     => $branchcode_1,
(-)a/t/db_dependent/Koha/Object.t (-2 / +3 lines)
Lines 604-610 subtest "Test update method" => sub { Link Here
604
604
605
subtest 'store() tests' => sub {
605
subtest 'store() tests' => sub {
606
606
607
    plan tests => 16;
607
    plan tests => 17;
608
608
609
    # Using Koha::ApiKey to test Koha::Object>-store
609
    # Using Koha::ApiKey to test Koha::Object>-store
610
    # Simple object with foreign keys and unique key
610
    # Simple object with foreign keys and unique key
Lines 701-706 subtest 'store() tests' => sub { Link Here
701
                rentalcharge    => "",
701
                rentalcharge    => "",
702
                notforloan      => "",
702
                notforloan      => "",
703
                hideinopac      => "",
703
                hideinopac      => "",
704
                updatenotforloanstatusoncheckin => "",
704
            }
705
            }
705
        )->store;
706
        )->store;
706
    };
707
    };
Lines 708-713 subtest 'store() tests' => sub { Link Here
708
    is( $itemtype->rentalcharge, undef, 'decimal DEFAULT NULL should default to null');
709
    is( $itemtype->rentalcharge, undef, 'decimal DEFAULT NULL should default to null');
709
    is( $itemtype->notforloan, undef, 'int DEFAULT NULL should default to null');
710
    is( $itemtype->notforloan, undef, 'int DEFAULT NULL should default to null');
710
    is( $itemtype->hideinopac, 0, 'int NOT NULL DEFAULT 0 should default to 0');
711
    is( $itemtype->hideinopac, 0, 'int NOT NULL DEFAULT 0 should default to 0');
712
    is( $itemtype->updatenotforloanstatusoncheckin, 1, 'int NOT NULL DEFAULT 1 should default to 1');
711
713
712
    subtest 'Bad value tests' => sub {
714
    subtest 'Bad value tests' => sub {
713
715
714
- 

Return to bug 25560