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

(-)a/t/db_dependent/Koha/Pseudonymization.t (-15 / +10 lines)
Lines 138-146 subtest 'Koha::Anonymized::Transactions tests' => sub { Link Here
138
    $schema->storage->txn_rollback;
138
    $schema->storage->txn_rollback;
139
};
139
};
140
140
141
subtest 'PseudonymizedBorrowerAttributes tests' => sub {
141
subtest 'PseudonymizedMetadataValues tests' => sub {
142
142
143
    plan tests => 3;
143
    plan tests => 5;
144
144
145
    $schema->storage->txn_begin;
145
    $schema->storage->txn_begin;
146
146
Lines 217-240 subtest 'PseudonymizedBorrowerAttributes tests' => sub { Link Here
217
217
218
    my $p = Koha::PseudonymizedTransaction->new_from_statistic($statistic)->store;
218
    my $p = Koha::PseudonymizedTransaction->new_from_statistic($statistic)->store;
219
    my $attributes =
219
    my $attributes =
220
        Koha::Database->new->schema->resultset('PseudonymizedBorrowerAttribute')
220
        Koha::Database->new->schema->resultset('PseudonymizedMetadataValue')
221
        ->search( { transaction_id => $p->id }, { order_by => 'attribute' } );
221
        ->search( { transaction_id => $p->id }, { order_by => 'value' } );
222
    is(
222
    is(
223
        $attributes->count, 2,
223
        $attributes->count, 2,
224
        'Only the 2 attributes that have a type with keep_for_pseudonymization set should be kept'
224
        'Only the 2 attributes that have a type with keep_for_pseudonymization set should be kept'
225
    );
225
    );
226
    my $attribute_1 = $attributes->next;
226
    my $attribute_1 = $attributes->next;
227
    is_deeply(
227
228
        { attribute => $attribute_1->attribute, code => $attribute_1->code->code },
228
    is( $attribute_1->value, $attribute_values->[0]->{attribute} );
229
        $attribute_values->[0],
229
    is( $attribute_1->key,   $attribute_values->[0]->{code} );
230
        'Attribute 1 should be retrieved correctly'
230
231
    );
232
    my $attribute_2 = $attributes->next;
231
    my $attribute_2 = $attributes->next;
233
    is_deeply(
232
    is( $attribute_2->value, $attribute_values->[2]->{attribute} );
234
        { attribute => $attribute_2->attribute, code => $attribute_2->code->code },
233
    is( $attribute_2->key,   $attribute_values->[2]->{code} );
235
        $attribute_values->[2],
236
        'Attribute 2 should be retrieved correctly'
237
    );
238
234
239
    $schema->storage->txn_rollback;
235
    $schema->storage->txn_rollback;
240
};
236
};
241
- 

Return to bug 37901