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

(-)a/t/db_dependent/Koha/Biblio.t (-1 / +115 lines)
Lines 1062-1067 subtest 'link_marc_host' => sub { Link Here
1062
    $schema->storage->txn_rollback;
1062
    $schema->storage->txn_rollback;
1063
};
1063
};
1064
1064
1065
subtest 'link_marc_bundled_item' => sub {
1066
    plan tests => 4;
1067
    $schema->storage->txn_begin;
1068
1069
    my $child = $builder->build_sample_item();
1070
1071
    my $host        = $builder->build_sample_biblio();
1072
    my $host_record = $host->metadata->record;
1073
1074
    is( $host_record->field('774'), undef, "774 field is undefined before link_marc_bundled_item" );
1075
    $host->link_marc_bundled_item( { bundled_item => $child->itemnumber } );
1076
    $host->discard_changes;
1077
    $host_record = $host->metadata->record;
1078
    is(
1079
        ref( $host_record->field('774') ), 'MARC::Field',
1080
        '774 field is set after calling link_marc_bundled_item({ bundled_item => $itemnumber })'
1081
    );
1082
1083
    $host        = $builder->build_sample_biblio();
1084
    $host_record = $host->metadata->record;
1085
    is( $host_record->field('774'), undef, "774 field is undefined before link_marc_bundled_item" );
1086
    $host->link_marc_bundled_item( { bundled_item => $child } );
1087
    $host->discard_changes;
1088
    $host_record = $host->metadata->record;
1089
    is(
1090
        ref( $host_record->field('774') ), 'MARC::Field',
1091
        '774 field is set after calling link_marc_bundled_item({ bundled_item => $biblio })'
1092
    );
1093
1094
    $schema->storage->txn_rollback;
1095
};
1096
1097
subtest 'unlink_marc_bundled_item' => sub {
1098
    plan tests => 8;
1099
    $schema->storage->txn_begin;
1100
    my $child       = $builder->build_sample_item();
1101
    my $wrongchild  = $builder->build_sample_item();
1102
    my $host        = $builder->build_sample_biblio();
1103
    my $host_record = $host->metadata->record;
1104
1105
    # Prepare the environment
1106
    $host->link_marc_bundled_item( { bundled_item => $child->itemnumber } );
1107
    $host->discard_changes;
1108
    $host_record = $host->metadata->record;
1109
    is(
1110
        ref( $host_record->field('774') ), 'MARC::Field',
1111
        '774 field is set before calling unlink_marc_bundled_item({ bundled_item => $itemnumber })'
1112
    );
1113
1114
    # Test
1115
    $host->unlink_marc_bundled_item( { bundled_item => $child->itemnumber } );
1116
    $host->discard_changes;
1117
    $host_record = $host->metadata->record;
1118
    is(
1119
        $host_record->field('774'), undef,
1120
        'Can remove a link to a bundle using a itemnumber to identify the bundle'
1121
    );
1122
1123
    # Prepare the environment
1124
    $host->link_marc_bundled_item( { bundled_item => $child->itemnumber } );
1125
    $host->discard_changes;
1126
    $host_record = $host->metadata->record;
1127
    is(
1128
        ref( $host_record->field('774') ), 'MARC::Field',
1129
        '774 field is set before calling unlink_marc_bundled_item({ bundled_item => $itemnumber })'
1130
    );
1131
1132
    # Test
1133
    $host->unlink_marc_bundled_item( { bundled_item => $child } );
1134
    $host->discard_changes;
1135
    $host_record = $host->metadata->record;
1136
    is(
1137
        $host_record->field('774'), undef,
1138
        'Can remove a link to a bundle using a record to identify the bundle'
1139
    );
1140
1141
    # Prepare the environment
1142
    $host->link_marc_bundled_item( { bundled_item => $child->itemnumber } );
1143
    $host->discard_changes;
1144
    $host_record = $host->metadata->record;
1145
    is(
1146
        ref( $host_record->field('774') ), 'MARC::Field',
1147
        '774 field is set before calling unlink_marc_bundled_item({ bundled_item => $itemnumber })'
1148
    );
1149
1150
    # Test
1151
    $host->unlink_marc_bundled_item( { bundled_item => $wrongchild->itemnumber } );
1152
    $host->discard_changes;
1153
    $host_record = $host->metadata->record;
1154
    is(
1155
        ref( $host_record->field('774') ), 'MARC::Field',
1156
        'Removing a link from another bundle does not remove the field'
1157
    );
1158
1159
    # Prepare the environment
1160
    $host->link_marc_bundled_item( { bundled_item => $child->itemnumber } );
1161
    $host->discard_changes;
1162
    $host_record = $host->metadata->record;
1163
    is(
1164
        ref( $host_record->field('774') ), 'MARC::Field',
1165
        '774 field is set before calling unlink_marc_bundled_item({ bundled_item => $itemnumber })'
1166
    );
1167
1168
    # Test
1169
    $host->unlink_marc_bundled_item( { bundled_item => $wrongchild } );
1170
    $host->discard_changes;
1171
    $host_record = $host->metadata->record;
1172
    is(
1173
        ref( $host_record->field('774') ), 'MARC::Field',
1174
        'Removing a link from another bundle does not remove the field'
1175
    );
1176
1177
    $schema->storage->txn_rollback;
1178
};
1179
1065
subtest '->orders, ->uncancelled_orders and ->acq_status tests' => sub {
1180
subtest '->orders, ->uncancelled_orders and ->acq_status tests' => sub {
1066
1181
1067
    plan tests => 9;
1182
    plan tests => 9;
1068
- 

Return to bug 38093