|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 39; |
20 |
use Test::More tests => 40; |
| 21 |
use Test::Exception; |
21 |
use Test::Exception; |
| 22 |
use Test::Warn; |
22 |
use Test::Warn; |
| 23 |
|
23 |
|
|
Lines 1071-1076
subtest 'link_marc_host' => sub {
Link Here
|
| 1071 |
$schema->storage->txn_rollback; |
1071 |
$schema->storage->txn_rollback; |
| 1072 |
}; |
1072 |
}; |
| 1073 |
|
1073 |
|
|
|
1074 |
subtest 'unlink_marc_host' => sub { |
| 1075 |
plan tests => 9; |
| 1076 |
$schema->storage->txn_begin; |
| 1077 |
my $host = $builder->build_sample_biblio(); |
| 1078 |
my $wronghost = $builder->build_sample_biblio(); |
| 1079 |
my $child = $builder->build_sample_biblio(); |
| 1080 |
my $child_record = $child->metadata->record; |
| 1081 |
|
| 1082 |
# Prepare the environment |
| 1083 |
$child->link_marc_host( { host => $host->biblionumber } ); |
| 1084 |
$child->discard_changes; |
| 1085 |
$child_record = $child->metadata->record; |
| 1086 |
is( |
| 1087 |
ref( $child_record->field('773') ), 'MARC::Field', |
| 1088 |
'773 field is set before calling unlink_marc_host({ host => $biblionumber })' |
| 1089 |
); |
| 1090 |
|
| 1091 |
# Test |
| 1092 |
$child->unlink_marc_host( { host => $host->biblionumber } ); |
| 1093 |
$child->discard_changes; |
| 1094 |
$child_record = $child->metadata->record; |
| 1095 |
is( |
| 1096 |
$child_record->field('773'), undef, |
| 1097 |
'Can remove a link to a bundle using a biblionumber to identify the bundle' |
| 1098 |
); |
| 1099 |
|
| 1100 |
# Prepare the environment |
| 1101 |
$child->link_marc_host( { host => $host->biblionumber } ); |
| 1102 |
$child->discard_changes; |
| 1103 |
$child_record = $child->metadata->record; |
| 1104 |
is( |
| 1105 |
ref( $child_record->field('773') ), 'MARC::Field', |
| 1106 |
'773 field is set before calling unlink_marc_host({ host => $biblionumber })' |
| 1107 |
); |
| 1108 |
|
| 1109 |
# Test |
| 1110 |
$child->unlink_marc_host( { host => $host } ); |
| 1111 |
$child->discard_changes; |
| 1112 |
$child_record = $child->metadata->record; |
| 1113 |
is( |
| 1114 |
$child_record->field('773'), undef, |
| 1115 |
'Can remove a link to a bundle using a record to identify the bundle' |
| 1116 |
); |
| 1117 |
|
| 1118 |
# Prepare the environment |
| 1119 |
$child->link_marc_host( { host => $host->biblionumber } ); |
| 1120 |
$child->discard_changes; |
| 1121 |
$child_record = $child->metadata->record; |
| 1122 |
is( |
| 1123 |
ref( $child_record->field('773') ), 'MARC::Field', |
| 1124 |
'773 field is set before calling unlink_marc_host({ host => $biblionumber })' |
| 1125 |
); |
| 1126 |
|
| 1127 |
# Test |
| 1128 |
$child->unlink_marc_host( { host => $wronghost->biblionumber } ); |
| 1129 |
$child->discard_changes; |
| 1130 |
$child_record = $child->metadata->record; |
| 1131 |
is( |
| 1132 |
ref( $child_record->field('773') ), 'MARC::Field', |
| 1133 |
'Removing a link from another bundle does not remove the field' |
| 1134 |
); |
| 1135 |
|
| 1136 |
# Prepare the environment |
| 1137 |
$child->link_marc_host( { host => $host->biblionumber } ); |
| 1138 |
$child->discard_changes; |
| 1139 |
$child_record = $child->metadata->record; |
| 1140 |
is( |
| 1141 |
ref( $child_record->field('773') ), 'MARC::Field', |
| 1142 |
'773 field is set before calling unlink_marc_host({ host => $biblionumber })' |
| 1143 |
); |
| 1144 |
|
| 1145 |
# Test |
| 1146 |
$child->unlink_marc_host( { host => $wronghost } ); |
| 1147 |
$child->discard_changes; |
| 1148 |
$child_record = $child->metadata->record; |
| 1149 |
is( |
| 1150 |
ref( $child_record->field('773') ), 'MARC::Field', |
| 1151 |
'Removing a link from another bundle does not remove the field' |
| 1152 |
); |
| 1153 |
|
| 1154 |
# Prepare the environment |
| 1155 |
$child->link_marc_host( { host => $host->biblionumber } ); |
| 1156 |
$child->link_marc_host( { host => $host->biblionumber } ); |
| 1157 |
$child->discard_changes; |
| 1158 |
$child_record = $child->metadata->record; |
| 1159 |
my @fields = $child_record->field('773'); |
| 1160 |
my $fields_before = scalar @fields; |
| 1161 |
|
| 1162 |
# Test |
| 1163 |
$child->unlink_marc_host( { host => $host } ); |
| 1164 |
$child->discard_changes; |
| 1165 |
$child_record = $child->metadata->record; |
| 1166 |
@fields = $child_record->field('773'); |
| 1167 |
my $fields_after = scalar @fields; |
| 1168 |
is( |
| 1169 |
$fields_after, $fields_before - 1, |
| 1170 |
'Removing a link only removes one link' |
| 1171 |
); |
| 1172 |
|
| 1173 |
$schema->storage->txn_rollback; |
| 1174 |
}; |
| 1175 |
|
| 1074 |
subtest '->orders, ->uncancelled_orders and ->acq_status tests' => sub { |
1176 |
subtest '->orders, ->uncancelled_orders and ->acq_status tests' => sub { |
| 1075 |
|
1177 |
|
| 1076 |
plan tests => 9; |
1178 |
plan tests => 9; |
| 1077 |
- |
|
|