|
Lines 1038-1044
subtest 'ModItemFromMarc' => sub {
Link Here
|
| 1038 |
}; |
1038 |
}; |
| 1039 |
|
1039 |
|
| 1040 |
subtest 'permanent_location' => sub { |
1040 |
subtest 'permanent_location' => sub { |
| 1041 |
plan tests => 6; |
1041 |
plan tests => 10; |
| 1042 |
|
1042 |
|
| 1043 |
# Make sure items.permanent_location is not mapped |
1043 |
# Make sure items.permanent_location is not mapped |
| 1044 |
Koha::MarcSubfieldStructures->search( |
1044 |
Koha::MarcSubfieldStructures->search( |
|
Lines 1047-1052
subtest 'ModItemFromMarc' => sub {
Link Here
|
| 1047 |
kohafield => 'items.permanent_location', |
1047 |
kohafield => 'items.permanent_location', |
| 1048 |
} |
1048 |
} |
| 1049 |
)->delete; |
1049 |
)->delete; |
|
|
1050 |
Koha::MarcSubfieldStructures->search( |
| 1051 |
{ |
| 1052 |
frameworkcode => q{}, |
| 1053 |
tagfield => '952', |
| 1054 |
tagsubfield => 'C', |
| 1055 |
} |
| 1056 |
)->delete; |
| 1050 |
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); |
1057 |
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); |
| 1051 |
|
1058 |
|
| 1052 |
my $item = $builder->build_sample_item; |
1059 |
my $item = $builder->build_sample_item; |
|
Lines 1072-1078
subtest 'ModItemFromMarc' => sub {
Link Here
|
| 1072 |
tagfield => '952', |
1079 |
tagfield => '952', |
| 1073 |
tagsubfield => 'C', |
1080 |
tagsubfield => 'C', |
| 1074 |
kohafield => 'items.permanent_location', |
1081 |
kohafield => 'items.permanent_location', |
| 1075 |
repeatable => 0 |
1082 |
repeatable => 0, |
|
|
1083 |
tab => 10, |
| 1084 |
hidden => 0, |
| 1076 |
} |
1085 |
} |
| 1077 |
)->store; |
1086 |
)->store; |
| 1078 |
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); |
1087 |
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" ); |
|
Lines 1085-1090
subtest 'ModItemFromMarc' => sub {
Link Here
|
| 1085 |
$item = $item->get_from_storage; |
1094 |
$item = $item->get_from_storage; |
| 1086 |
is( $item->location, 'C', 'next new location set as expected' ); |
1095 |
is( $item->location, 'C', 'next new location set as expected' ); |
| 1087 |
is( $item->permanent_location, 'B', 'permanent location remains unchanged as expected' ); |
1096 |
is( $item->permanent_location, 'B', 'permanent location remains unchanged as expected' ); |
|
|
1097 |
|
| 1098 |
$item->permanent_location(undef)->more_subfields_xml(undef)->store; |
| 1099 |
# Clear values from the DB |
| 1100 |
$item = $item->get_from_storage; |
| 1101 |
|
| 1102 |
# Update the location |
| 1103 |
$item->location('D'); |
| 1104 |
$marc = C4::Items::Item2Marc( $item->unblessed, $item->biblionumber ); |
| 1105 |
# Remove the permanent_location field from the form |
| 1106 |
$marc->field('952')->delete_subfield("C"); |
| 1107 |
ModItemFromMarc( $marc, $item->biblionumber, $item->itemnumber ); |
| 1108 |
$item = $item->get_from_storage; |
| 1109 |
is( $item->location, 'D', 'next new location set as expected' ); |
| 1110 |
is( $item->permanent_location, 'D', 'permanent location is updated if not previously set and no value passed' ); |
| 1111 |
|
| 1112 |
# Clear values from the DB |
| 1113 |
$item->permanent_location(undef)->more_subfields_xml(undef)->store; |
| 1114 |
$item = $item->get_from_storage; |
| 1115 |
|
| 1116 |
# This time nothing is set, but we pass an emty string |
| 1117 |
$item->permanent_location(""); |
| 1118 |
$item->location('E'); |
| 1119 |
$marc = C4::Items::Item2Marc( $item->unblessed, $item->biblionumber ); |
| 1120 |
ModItemFromMarc( $marc, $item->biblionumber, $item->itemnumber ); |
| 1121 |
$item = $item->get_from_storage; |
| 1122 |
is( $item->location, 'E', 'next new location set as expected' ); |
| 1123 |
is( $item->permanent_location, undef, 'permanent location is not updated if previously set as blank string' ); |
| 1124 |
|
| 1088 |
}; |
1125 |
}; |
| 1089 |
|
1126 |
|
| 1090 |
$schema->storage->txn_rollback; |
1127 |
$schema->storage->txn_rollback; |
| 1091 |
- |
|
|