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

(-)a/t/db_dependent/Items.t (-2 / +42 lines)
Lines 981-987 subtest 'Split subfields in Item2Marc (Bug 21774)' => sub { Link Here
981
};
981
};
982
982
983
subtest 'ModItemFromMarc' => sub {
983
subtest 'ModItemFromMarc' => sub {
984
    plan tests => 5;
984
    plan tests => 6;
985
    $schema->storage->txn_begin;
985
    $schema->storage->txn_begin;
986
986
987
    my $builder = t::lib::TestBuilder->new;
987
    my $builder = t::lib::TestBuilder->new;
Lines 1037-1041 subtest 'ModItemFromMarc' => sub { Link Here
1037
        is( $item->get_from_storage->cn_sort, 'YYY', 'cn_sort has been updated' );
1037
        is( $item->get_from_storage->cn_sort, 'YYY', 'cn_sort has been updated' );
1038
    };
1038
    };
1039
1039
1040
    subtest 'permanent_location' => sub {
1041
        plan tests => 6;
1042
1043
        my $item = $builder->build_sample_item;
1044
1045
        # By default, setting location to something new should set permanent location to the same thing
1046
        # with the usual exceptions
1047
        $item->set({ location => 'A', permanent_location => 'A' })->store;
1048
        is( $item->location, 'A', 'initial location set as expected' );
1049
        is( $item->permanent_location, 'A', 'initial permanent location set as expected' );
1050
1051
        $item->location('B');
1052
        my $marc = C4::Items::Item2Marc( $item->unblessed, $item->biblionumber );
1053
        ModItemFromMarc( $marc, $item->biblionumber, $item->itemnumber );
1054
1055
        $item = $item->get_from_storage;
1056
        is( $item->location, 'B', 'new location set as expected' );
1057
        is( $item->permanent_location, 'B', 'new permanent location set as expected' );
1058
1059
        # Added a marc mapping for permanent location, allows it to be edited independently
1060
        my $mapping = Koha::MarcSubfieldStructure->new(
1061
            {
1062
                frameworkcode => q{},
1063
                tagfield      => '952',
1064
                tagsubfield   => 'C',
1065
                kohafield     => 'items.permanent_location',
1066
                repeatable    => 0
1067
            }
1068
        )->store;
1069
        Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
1070
1071
        # Now if we change location, and also pass in a permanent location
1072
        # the permanent_location will not be overwritten by location
1073
        $item->location('C');
1074
        $marc = C4::Items::Item2Marc( $item->unblessed, $item->biblionumber );
1075
        ModItemFromMarc( $marc, $item->biblionumber, $item->itemnumber );
1076
        $item = $item->get_from_storage;
1077
        is( $item->location, 'C', 'next new location set as expected' );
1078
        is( $item->permanent_location, 'B', 'permanent location remains unchanged as expected' );
1079
    };
1080
1040
    $schema->storage->txn_rollback;
1081
    $schema->storage->txn_rollback;
1041
};
1082
};
1042
- 

Return to bug 27837