From cf83134e82070e262aaacc338410b0ff18e4abce Mon Sep 17 00:00:00 2001 From: Victor Grousset/tuxayo Date: Fri, 9 Feb 2024 18:43:10 +0100 Subject: [PATCH] Bug 16117: (QA follow-up): tidy up code & fix test name --- Koha/Statistic.pm | 5 +++-- Koha/Statistics.pm | 4 ++-- installer/data/mysql/atomicupdate/bug_16117.pl | 13 ++++++++----- t/db_dependent/Koha/Statistics.t | 4 ++-- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Koha/Statistic.pm b/Koha/Statistic.pm index aeaace4796..e1e3dc4e37 100644 --- a/Koha/Statistic.pm +++ b/Koha/Statistic.pm @@ -27,8 +27,9 @@ use Koha::BackgroundJob::PseudonymizeStatistic; use base qw(Koha::Object); -our @allowed_accounts_types = qw( writeoff payment ); -our @allowed_circulation_types = qw( renew issue localuse return onsite_checkout recall item_found item_lost invalid_item invalid_patron); +our @allowed_accounts_types = qw( writeoff payment ); +our @allowed_circulation_types = + qw( renew issue localuse return onsite_checkout recall item_found item_lost invalid_item invalid_patron); our @mandatory_accounts_keys = qw( type branch borrowernumber value ); # note that amount is mapped to value our @mandatory_circulation_keys = qw( type branch borrowernumber itemnumber ccode itemtype ); diff --git a/Koha/Statistics.pm b/Koha/Statistics.pm index 219da6867e..af43ba1817 100644 --- a/Koha/Statistics.pm +++ b/Koha/Statistics.pm @@ -87,8 +87,8 @@ sub _log_invalid_value { my $type = $params->{type}; my $value = $params->{value}; - my $branch = C4::Context->userenv ? C4::Context->userenv->{branch} : undef; - my $dt = dt_from_string(); + my $branch = C4::Context->userenv ? C4::Context->userenv->{branch} : undef; + my $dt = dt_from_string(); my $borrowernumber = C4::Context->userenv->{'number'}; return Koha::Statistic->new( diff --git a/installer/data/mysql/atomicupdate/bug_16117.pl b/installer/data/mysql/atomicupdate/bug_16117.pl index 21510aeaa8..2d98bb5717 100755 --- a/installer/data/mysql/atomicupdate/bug_16117.pl +++ b/installer/data/mysql/atomicupdate/bug_16117.pl @@ -1,17 +1,20 @@ use Modern::Perl; return { - bug_number => "16117", + bug_number => "16117", description => "Log invalid borrower cardnumbers and item barcodes", - up => sub { + up => sub { my ($args) = @_; - my ($dbh, $out) = @$args{qw(dbh out)}; + my ( $dbh, $out ) = @$args{qw(dbh out)}; - $dbh->do(q{ + $dbh->do( + q{ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('LogInvalidItems','0','','Log scanned invalid item identifiers as statistics','YesNo'), ('LogInvalidPatrons','0','','Log scanned invalid patron identifiers as statistics','YesNo'); - }); + } + ); + # sysprefs say $out "Added new system preference 'LogInvalidItems'"; say $out "Added new system preference 'LogInvalidPatrons'"; diff --git a/t/db_dependent/Koha/Statistics.t b/t/db_dependent/Koha/Statistics.t index 6cfc2c6174..b140278a07 100755 --- a/t/db_dependent/Koha/Statistics.t +++ b/t/db_dependent/Koha/Statistics.t @@ -196,7 +196,7 @@ subtest 'Log borrower cardnumbers and item barcodes which are not valid' => sub Koha::Statistics->log_invalid_patron( { patron => 'InvalidCardnumber' } ); my $stat = Koha::Statistics->search()->next(); is( $stat->type, 'invalid_patron', 'Type set to invalid_patron' ); - is( $stat->borrowernumber, '-1', 'Associated library id set correctly' ); + is( $stat->borrowernumber, '-1', 'Associated patron id set correctly' ); is( $stat->other, 'InvalidCardnumber', 'Invalid cardnumber is set correctly' ); is( $stat->branch, $branchcode, 'Branchcode is set correctly' ); @@ -210,7 +210,7 @@ subtest 'Log borrower cardnumbers and item barcodes which are not valid' => sub Koha::Statistics->log_invalid_item( { item => 'InvalidBarcode' } ); $stat = Koha::Statistics->search()->next(); is( $stat->type, 'invalid_item', 'Type set to invalid_item' ); - is( $stat->borrowernumber, '-1', 'Associated library id set correctly' ); + is( $stat->borrowernumber, '-1', 'Associated patron id set correctly' ); is( $stat->other, 'InvalidBarcode', 'Invalid barcode is set correctly' ); is( $stat->branch, $branchcode, 'Branchcode is set correctly' ); -- 2.43.0