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

(-)a/t/db_dependent/Circulation/Returns.t (-5 / +10 lines)
Lines 19-27 use Modern::Perl; Link Here
19
19
20
use Test::More tests => 3;
20
use Test::More tests => 3;
21
use Test::MockModule;
21
use Test::MockModule;
22
use t::lib::TestBuilder;
22
use Test::Warn;
23
23
24
use t::lib::Mocks;
24
use t::lib::Mocks;
25
use t::lib::TestBuilder;
26
25
use C4::Biblio;
27
use C4::Biblio;
26
use C4::Circulation;
28
use C4::Circulation;
27
use C4::Items;
29
use C4::Items;
Lines 89-95 subtest "InProcessingToShelvingCart tests" => sub { Link Here
89
91
90
subtest "AddReturn logging on statistics table (item-level_itypes=1)" => sub {
92
subtest "AddReturn logging on statistics table (item-level_itypes=1)" => sub {
91
93
92
    plan tests => 2;
94
    plan tests => 4;
93
95
94
    # Set item-level item types
96
    # Set item-level item types
95
    t::lib::Mocks::mock_preference( "item-level_itypes", 1 );
97
    t::lib::Mocks::mock_preference( "item-level_itypes", 1 );
Lines 160-168 subtest "AddReturn logging on statistics table (item-level_itypes=1)" => sub { Link Here
160
162
161
    is( $stat->itemtype, $ilevel_itemtype,
163
    is( $stat->itemtype, $ilevel_itemtype,
162
        "item-level itype recorded on statistics for return");
164
        "item-level itype recorded on statistics for return");
163
165
    warning_like { AddIssue( $borrower, $item_without_itemtype->{ barcode } ) }
164
    AddIssue( $borrower, $item_without_itemtype->{ barcode } );
166
                 qr/^item-level_itypes set but no itemtype set for item/,
165
    AddReturn( $item_without_itemtype->{ barcode }, $branch );
167
                 'Item without itemtype set raises warning on AddIssue';
168
    warning_like { AddReturn( $item_without_itemtype->{ barcode }, $branch ) }
169
                 qr/^item-level_itypes set but no itemtype set for item/,
170
                 'Item without itemtype set raises warning on AddReturn';
166
    # Test biblio-level itemtype was recorded on the 'statistics' table
171
    # Test biblio-level itemtype was recorded on the 'statistics' table
167
    $stat = $schema->resultset('Statistic')->search({
172
    $stat = $schema->resultset('Statistic')->search({
168
        branch     => $branch,
173
        branch     => $branch,
(-)a/t/db_dependent/Items.t (-3 / +24 lines)
Lines 418-424 subtest 'SearchItems test' => sub { Link Here
418
418
419
    my $item3_record = new MARC::Record;
419
    my $item3_record = new MARC::Record;
420
    $item3_record->append_fields(
420
    $item3_record->append_fields(
421
        new MARC::Field($itemfield, '', '', 'z' => 'foobar')
421
        new MARC::Field(
422
            $itemfield, '', '',
423
            'z' => 'foobar',
424
            'y' => $itemtype->{itemtype}
425
        )
422
    );
426
    );
423
    my (undef, undef, $item3_itemnumber) = AddItemFromMarc($item3_record,
427
    my (undef, undef, $item3_itemnumber) = AddItemFromMarc($item3_record,
424
        $biblionumber);
428
        $biblionumber);
Lines 652-657 subtest 'C4::Items::_build_default_values_for_mod_marc' => sub { Link Here
652
        }
656
        }
653
    });
657
    });
654
658
659
    my $mss_itemtype = $builder->build({
660
        source => 'MarcSubfieldStructure',
661
        value => {
662
            frameworkcode => $framework->{frameworkcode},
663
            kohafield => 'items.itype',
664
            tagfield => '952',
665
            tagsubfield => 'y',
666
        }
667
    });
668
669
    my $itemtype = $builder->build({ source => 'Itemtype' })->{itemtype};
670
655
    # Create a record with a barcode
671
    # Create a record with a barcode
656
    my ($biblionumber) = get_biblio( $framework->{frameworkcode} );
672
    my ($biblionumber) = get_biblio( $framework->{frameworkcode} );
657
    my $item_record = new MARC::Record;
673
    my $item_record = new MARC::Record;
Lines 659-674 subtest 'C4::Items::_build_default_values_for_mod_marc' => sub { Link Here
659
    my $barcode_field = MARC::Field->new(
675
    my $barcode_field = MARC::Field->new(
660
        '952', ' ', ' ',
676
        '952', ' ', ' ',
661
        p => $a_barcode,
677
        p => $a_barcode,
678
        y => $itemtype
679
    );
680
    my $itemtype_field = MARC::Field->new(
681
        '952', ' ', ' ',
682
        y => $itemtype
662
    );
683
    );
663
    $item_record->append_fields( $barcode_field );
684
    $item_record->append_fields( $barcode_field );
664
    my (undef, undef, $item_itemnumber) = AddItemFromMarc($item_record, $biblionumber);
685
    my (undef, undef, $item_itemnumber) = AddItemFromMarc($item_record, $biblionumber);
665
686
    use Data::Printer colored => 1;
666
    # Make sure everything has been set up
687
    # Make sure everything has been set up
667
    my $item = GetItem($item_itemnumber);
688
    my $item = GetItem($item_itemnumber);
668
    is( $item->{barcode}, $a_barcode, 'Everything has been set up correctly, the barcode is defined as expected' );
689
    is( $item->{barcode}, $a_barcode, 'Everything has been set up correctly, the barcode is defined as expected' );
669
690
670
    # Delete the barcode field and save the record
691
    # Delete the barcode field and save the record
671
    $item_record->delete_fields( $barcode_field );
692
    $item_record->delete_fields( $barcode_field );
693
    $item_record->append_fields( $itemtype_field ); # itemtype is mandatory
672
    ModItemFromMarc($item_record, $biblionumber, $item_itemnumber);
694
    ModItemFromMarc($item_record, $biblionumber, $item_itemnumber);
673
    $item = GetItem($item_itemnumber);
695
    $item = GetItem($item_itemnumber);
674
    is( $item->{barcode}, undef, 'The default value should have been set to the barcode, the field is mapped to a kohafield' );
696
    is( $item->{barcode}, undef, 'The default value should have been set to the barcode, the field is mapped to a kohafield' );
675
- 

Return to bug 17633