Bug 39652: Rename new_from_statistic

This new method name better reflects the fact that it now creates - and stores - the PseudonymizedTransaction object

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Pedro Amorim 2025-04-17 15:55:23 +00:00 committed by Katrin Fischer
parent f23632a352
commit 54205bd6ba
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
4 changed files with 12 additions and 12 deletions

View File

@ -52,7 +52,7 @@ sub process {
$self->start;
my $statistic = $args->{statistic};
my $stat_object = Koha::Statistic->new($statistic);
Koha::PseudonymizedTransaction->new_from_statistic($stat_object);
Koha::PseudonymizedTransaction->create_from_statistic($stat_object);
$self->finish( { data => "" } ); # We want to clear the job data to avoid storing patron information
}

View File

@ -33,13 +33,13 @@ Koha::PseudonymizedTransaction - Koha Koha::PseudonymizedTransaction Object clas
=head2 Class methods
=head3 new_from_statistic
=head3 create_from_statistic
Creates new object from a passed Koha::Statistic object
Creates a new object from a passed Koha::Statistic object and stores it in the database
=cut
sub new_from_statistic {
sub create_from_statistic {
my ( $class, $statistic ) = @_;
my $values = {

View File

@ -64,7 +64,7 @@ subtest 'Config does not exist' => sub {
ccode => $item->ccode,
}
);
my $pseudo = Koha::PseudonymizedTransaction->new_from_statistic($stat);
my $pseudo = Koha::PseudonymizedTransaction->create_from_statistic($stat);
} catch {
ok(
@ -119,7 +119,7 @@ subtest 'Koha::Anonymized::Transactions tests' => sub {
["Called"], "Background job enqueued when pseudonymization enabled";
my $statistic = Koha::Statistics->search( { itemnumber => $item->itemnumber } )->next;
my $pseudonymized = Koha::PseudonymizedTransaction->new_from_statistic($statistic);
my $pseudonymized = Koha::PseudonymizedTransaction->create_from_statistic($statistic);
like(
$pseudonymized->hashed_borrowernumber,
qr{^\$2a\$08\$}, "The hashed_borrowernumber must be a bcrypt hash"
@ -135,7 +135,7 @@ subtest 'Koha::Anonymized::Transactions tests' => sub {
is( $pseudonymized->itemcallnumber, $item->itemcallnumber, 'itemcallnumber copied correctly' );
is( $pseudonymized->ccode, $item->ccode, 'ccode copied correctly' );
my $next_p = Koha::PseudonymizedTransaction->new_from_statistic($statistic);
my $next_p = Koha::PseudonymizedTransaction->create_from_statistic($statistic);
isnt(
$pseudonymized->id,
@ -223,7 +223,7 @@ subtest 'PseudonymizedBorrowerAttributes tests' => sub {
}
);
my $p = Koha::PseudonymizedTransaction->new_from_statistic($statistic);
my $p = Koha::PseudonymizedTransaction->create_from_statistic($statistic);
my $attributes =
Koha::Database->new->schema->resultset('PseudonymizedBorrowerAttribute')
->search( { transaction_id => $p->id }, { order_by => 'attribute' } );
@ -258,7 +258,7 @@ subtest 'PseudonymizedBorrowerAttributes tests' => sub {
}
);
my $next_p = Koha::PseudonymizedTransaction->new_from_statistic($second_statistic);
my $next_p = Koha::PseudonymizedTransaction->create_from_statistic($second_statistic);
my $next_attributes =
Koha::Database->new->schema->resultset('PseudonymizedBorrowerAttribute')
->search( { transaction_id => $next_p->id }, { order_by => 'attribute' } );

View File

@ -57,7 +57,7 @@ subtest 'get_hash() tests' => sub {
);
};
subtest 'new_from_statistic() tests' => sub {
subtest 'create_from_statistic() tests' => sub {
plan tests => 15;
@ -101,7 +101,7 @@ subtest 'new_from_statistic() tests' => sub {
}
);
my $pseudonymized = Koha::PseudonymizedTransaction->new_from_statistic($statistic);
my $pseudonymized = Koha::PseudonymizedTransaction->create_from_statistic($statistic);
is(
$pseudonymized->hashed_borrowernumber,
@ -124,7 +124,7 @@ subtest 'new_from_statistic() tests' => sub {
$patron->cardnumber(undef)->store;
ok(
!Koha::PseudonymizedTransaction->new_from_statistic($statistic)->has_cardnumber,
!Koha::PseudonymizedTransaction->create_from_statistic($statistic)->has_cardnumber,
'has_cardnumber set to false'
);