From 9b1e564e54466eee963461c0a0097b5fac2e0cc9 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 17 Apr 2025 15:55:23 +0000 Subject: [PATCH] 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 --- Koha/BackgroundJob/PseudonymizeStatistic.pm | 2 +- Koha/PseudonymizedTransaction.pm | 6 +++--- t/db_dependent/Koha/Pseudonymization.t | 10 +++++----- t/db_dependent/Koha/PseudonymizedTransaction.t | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Koha/BackgroundJob/PseudonymizeStatistic.pm b/Koha/BackgroundJob/PseudonymizeStatistic.pm index 822ee6c856..550a0153bb 100644 --- a/Koha/BackgroundJob/PseudonymizeStatistic.pm +++ b/Koha/BackgroundJob/PseudonymizeStatistic.pm @@ -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 } diff --git a/Koha/PseudonymizedTransaction.pm b/Koha/PseudonymizedTransaction.pm index f456c4d840..526411a408 100644 --- a/Koha/PseudonymizedTransaction.pm +++ b/Koha/PseudonymizedTransaction.pm @@ -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 = { diff --git a/t/db_dependent/Koha/Pseudonymization.t b/t/db_dependent/Koha/Pseudonymization.t index 3f73c778f4..ca3461c119 100755 --- a/t/db_dependent/Koha/Pseudonymization.t +++ b/t/db_dependent/Koha/Pseudonymization.t @@ -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' } ); diff --git a/t/db_dependent/Koha/PseudonymizedTransaction.t b/t/db_dependent/Koha/PseudonymizedTransaction.t index 11e247f6d0..162688775f 100755 --- a/t/db_dependent/Koha/PseudonymizedTransaction.t +++ b/t/db_dependent/Koha/PseudonymizedTransaction.t @@ -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' ); -- 2.39.5