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

(-)a/Koha/BackgroundJob/PseudonymizeStatistic.pm (-1 / +1 lines)
Lines 52-58 sub process { Link Here
52
    $self->start;
52
    $self->start;
53
    my $statistic   = $args->{statistic};
53
    my $statistic   = $args->{statistic};
54
    my $stat_object = Koha::Statistic->new($statistic);
54
    my $stat_object = Koha::Statistic->new($statistic);
55
    Koha::PseudonymizedTransaction->new_from_statistic($stat_object);
55
    Koha::PseudonymizedTransaction->create_from_statistic($stat_object);
56
    $self->finish( { data => "" } );    # We want to clear the job data to avoid storing patron information
56
    $self->finish( { data => "" } );    # We want to clear the job data to avoid storing patron information
57
57
58
}
58
}
(-)a/Koha/PseudonymizedTransaction.pm (-3 / +3 lines)
Lines 33-45 Koha::PseudonymizedTransaction - Koha Koha::PseudonymizedTransaction Object clas Link Here
33
33
34
=head2 Class methods
34
=head2 Class methods
35
35
36
=head3 new_from_statistic
36
=head3 create_from_statistic
37
37
38
    Creates new object from a passed Koha::Statistic object
38
    Creates a new object from a passed Koha::Statistic object and stores it in the database
39
39
40
=cut
40
=cut
41
41
42
sub new_from_statistic {
42
sub create_from_statistic {
43
    my ( $class, $statistic ) = @_;
43
    my ( $class, $statistic ) = @_;
44
44
45
    my $values = {
45
    my $values = {
(-)a/t/db_dependent/Koha/Pseudonymization.t (-5 / +5 lines)
Lines 64-70 subtest 'Config does not exist' => sub { Link Here
64
                ccode          => $item->ccode,
64
                ccode          => $item->ccode,
65
            }
65
            }
66
        );
66
        );
67
        my $pseudo = Koha::PseudonymizedTransaction->new_from_statistic($stat);
67
        my $pseudo = Koha::PseudonymizedTransaction->create_from_statistic($stat);
68
68
69
    } catch {
69
    } catch {
70
        ok(
70
        ok(
Lines 119-125 subtest 'Koha::Anonymized::Transactions tests' => sub { Link Here
119
    ["Called"], "Background job enqueued when pseudonymization enabled";
119
    ["Called"], "Background job enqueued when pseudonymization enabled";
120
120
121
    my $statistic     = Koha::Statistics->search( { itemnumber => $item->itemnumber } )->next;
121
    my $statistic     = Koha::Statistics->search( { itemnumber => $item->itemnumber } )->next;
122
    my $pseudonymized = Koha::PseudonymizedTransaction->new_from_statistic($statistic);
122
    my $pseudonymized = Koha::PseudonymizedTransaction->create_from_statistic($statistic);
123
    like(
123
    like(
124
        $pseudonymized->hashed_borrowernumber,
124
        $pseudonymized->hashed_borrowernumber,
125
        qr{^\$2a\$08\$}, "The hashed_borrowernumber must be a bcrypt hash"
125
        qr{^\$2a\$08\$}, "The hashed_borrowernumber must be a bcrypt hash"
Lines 135-141 subtest 'Koha::Anonymized::Transactions tests' => sub { Link Here
135
    is( $pseudonymized->itemcallnumber,         $item->itemcallnumber,     'itemcallnumber copied correctly' );
135
    is( $pseudonymized->itemcallnumber,         $item->itemcallnumber,     'itemcallnumber copied correctly' );
136
    is( $pseudonymized->ccode,                  $item->ccode,              'ccode copied correctly' );
136
    is( $pseudonymized->ccode,                  $item->ccode,              'ccode copied correctly' );
137
137
138
    my $next_p = Koha::PseudonymizedTransaction->new_from_statistic($statistic);
138
    my $next_p = Koha::PseudonymizedTransaction->create_from_statistic($statistic);
139
139
140
    isnt(
140
    isnt(
141
        $pseudonymized->id,
141
        $pseudonymized->id,
Lines 223-229 subtest 'PseudonymizedBorrowerAttributes tests' => sub { Link Here
223
        }
223
        }
224
    );
224
    );
225
225
226
    my $p = Koha::PseudonymizedTransaction->new_from_statistic($statistic);
226
    my $p = Koha::PseudonymizedTransaction->create_from_statistic($statistic);
227
    my $attributes =
227
    my $attributes =
228
        Koha::Database->new->schema->resultset('PseudonymizedBorrowerAttribute')
228
        Koha::Database->new->schema->resultset('PseudonymizedBorrowerAttribute')
229
        ->search( { transaction_id => $p->id }, { order_by => 'attribute' } );
229
        ->search( { transaction_id => $p->id }, { order_by => 'attribute' } );
Lines 258-264 subtest 'PseudonymizedBorrowerAttributes tests' => sub { Link Here
258
        }
258
        }
259
    );
259
    );
260
260
261
    my $next_p = Koha::PseudonymizedTransaction->new_from_statistic($second_statistic);
261
    my $next_p = Koha::PseudonymizedTransaction->create_from_statistic($second_statistic);
262
    my $next_attributes =
262
    my $next_attributes =
263
        Koha::Database->new->schema->resultset('PseudonymizedBorrowerAttribute')
263
        Koha::Database->new->schema->resultset('PseudonymizedBorrowerAttribute')
264
        ->search( { transaction_id => $next_p->id }, { order_by => 'attribute' } );
264
        ->search( { transaction_id => $next_p->id }, { order_by => 'attribute' } );
(-)a/t/db_dependent/Koha/PseudonymizedTransaction.t (-4 / +3 lines)
Lines 57-63 subtest 'get_hash() tests' => sub { Link Here
57
    );
57
    );
58
};
58
};
59
59
60
subtest 'new_from_statistic() tests' => sub {
60
subtest 'create_from_statistic() tests' => sub {
61
61
62
    plan tests => 15;
62
    plan tests => 15;
63
63
Lines 101-107 subtest 'new_from_statistic() tests' => sub { Link Here
101
        }
101
        }
102
    );
102
    );
103
103
104
    my $pseudonymized = Koha::PseudonymizedTransaction->new_from_statistic($statistic);
104
    my $pseudonymized = Koha::PseudonymizedTransaction->create_from_statistic($statistic);
105
105
106
    is(
106
    is(
107
        $pseudonymized->hashed_borrowernumber,
107
        $pseudonymized->hashed_borrowernumber,
Lines 124-130 subtest 'new_from_statistic() tests' => sub { Link Here
124
    $patron->cardnumber(undef)->store;
124
    $patron->cardnumber(undef)->store;
125
125
126
    ok(
126
    ok(
127
        !Koha::PseudonymizedTransaction->new_from_statistic($statistic)->has_cardnumber,
127
        !Koha::PseudonymizedTransaction->create_from_statistic($statistic)->has_cardnumber,
128
        'has_cardnumber set to false'
128
        'has_cardnumber set to false'
129
    );
129
    );
130
130
131
- 

Return to bug 39652