From 40cc7c32832c9b711d0a8256f324e26ac4c31067 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 2 Mar 2022 09:19:55 -0300 Subject: [PATCH] Bug 30007: (follow-up) Adjust Koha::Patrons->search_patrons_to_anonymise tests Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/Koha/Patrons.t | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t index e7c49fc14e..54add04d60 100755 --- a/t/db_dependent/Koha/Patrons.t +++ b/t/db_dependent/Koha/Patrons.t @@ -1172,7 +1172,8 @@ subtest 'search_patrons_to_anonymise' => sub { t::lib::Mocks::mock_preference( 'AnonymousPatron', '' ); subtest 'AnonymousPatron is not defined' => sub { - plan tests => 3; + + plan tests => 2; t::lib::Mocks::mock_preference('IndependentBranches', 0); my $patron = $builder->build( @@ -1192,22 +1193,9 @@ subtest 'search_patrons_to_anonymise' => sub { my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->barcode, undef, undef, dt_from_string('2010-10-10') ); is( $returned, 1, 'The item should have been returned' ); - my $rows_affected = Koha::Old::Checkouts->search( - { - borrowernumber => [ - Koha::Patrons->search_patrons_to_anonymise( - { before => '2010-10-11' } - )->get_column('borrowernumber') - ] - } - )->anonymize; - ok( $rows_affected > 0, 'AnonymiseIssueHistory should affect at least 1 row' ); + my $patrons_to_anonymize = Koha::Patrons->search_patrons_to_anonymise( { before => '2010-10-11' } ); + ok( $patrons_to_anonymize->count > 0, 'search_patrons_to_anonymize' ); - my $dbh = C4::Context->dbh; - my ($borrowernumber_used_to_anonymised) = $dbh->selectrow_array(q| - SELECT borrowernumber FROM old_issues where itemnumber = ? - |, undef, $item->itemnumber); - is( $borrowernumber_used_to_anonymised, undef, 'With AnonymousPatron is not defined, the issue should have been anonymised anyway' ); Koha::Patrons->find( $patron->{borrowernumber})->delete; }; -- 2.35.1