Bugzilla – Attachment 122970 Details for
Bug 23260
Anonymize (remove) patron data from items_last_borrower
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23260: (follow-up) Update test
Bug-23260-follow-up-Update-test.patch (text/plain), 4.88 KB, created by
Nick Clemens (kidclamp)
on 2021-07-20 12:42:53 UTC
(
hide
)
Description:
Bug 23260: (follow-up) Update test
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2021-07-20 12:42:53 UTC
Size:
4.88 KB
patch
obsolete
>From b989d548d735e2dd0f804befe164d948e4ead4ad Mon Sep 17 00:00:00 2001 >From: Agustin Moyano <agustinmoyano@theke.io> >Date: Fri, 30 Oct 2020 13:14:12 -0300 >Subject: [PATCH] Bug 23260: (follow-up) Update test > >Update test count >--- > t/db_dependent/Koha/Patrons.t | 68 ++++++++++++++++++++++++++++++++--- > 1 file changed, 63 insertions(+), 5 deletions(-) > >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index f50b5f1a39..7d6bd81165 100755 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 42; >+use Test::More tests => 43; > use Test::Warn; > use Test::Exception; > use Test::MockModule; >@@ -1212,16 +1212,71 @@ subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub { > }; > > subtest 'anonymise items_last_borrower' => sub { >- plan tests => 1; >+ plan tests => 2; > > my $anonymous = $builder->build_object( { class => 'Koha::Patrons', }, ); > > t::lib::Mocks::mock_preference( 'AnonymousPatron', $anonymous->borrowernumber ); > t::lib::Mocks::mock_preference('StoreLastBorrower', 1); >+ t::lib::Mocks::mock_preference('AnonymiseLastBorrower', 1); >+ >+ subtest 'anonymise items_last_borrower by days' => sub { >+ plan tests => 4; >+ >+ t::lib::Mocks::mock_preference('AnonymiseLastBorrowerDays', 5); >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { privacy => 1, } >+ } >+ ); >+ my $item_1 = $builder->build_sample_item; >+ my $issue_1 = $builder->build_object( >+ { >+ class => 'Koha::Checkouts', >+ value => { >+ borrowernumber => $patron->borrowernumber, >+ itemnumber => $item_1->itemnumber, >+ }, >+ } >+ ); >+ my $item_2 = $builder->build_sample_item; >+ my $issue_2 = $builder->build_object( >+ { >+ class => 'Koha::Checkouts', >+ value => { >+ borrowernumber => $patron->borrowernumber, >+ itemnumber => $item_2->itemnumber, >+ }, >+ } >+ ); >+ >+ my $dbh = C4::Context->dbh; >+ my ( $returned_1 ) = C4::Circulation::AddReturn( $item_1->barcode, undef, undef, dt_from_string ); >+ my ( $returned_2 ) = C4::Circulation::AddReturn( $item_2->barcode, undef, undef, dt_from_string ); >+ is( $returned_1 && $returned_2, 1, 'The items should have been returned' ); >+ my $stu = $dbh->prepare(q|UPDATE items_last_borrower set created_on = ? where itemnumber = ?|); >+ $stu->execute(DateTime->today(time_zone => C4::Context->tz())->add( days => -6 ), $item_2->itemnumber); >+ >+ my $nb_rows = Koha::Patrons->anonymise_last_borrowers(); >+ is( $nb_rows, 1, 'anonymise_issue_history should have returned the number of last borrowers anonymised'); >+ >+ my $sth = $dbh->prepare(q|SELECT borrowernumber FROM items_last_borrower where itemnumber = ?|); >+ $sth->execute($item_1->itemnumber); >+ my ($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; >+ is( $borrowernumber_used_to_anonymised, $patron->borrowernumber, 'Last borrower younger than 5 days are not anonymised' ); >+ $sth->execute($item_2->itemnumber); >+ ($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; >+ is( $borrowernumber_used_to_anonymised, $anonymous->borrowernumber, 'Last borrower older than 5 days are anonymised' ); >+ >+ }; > > subtest 'withrawn, lost and damaged items' => sub { > plan tests => 6; > >+ t::lib::Mocks::mock_preference('AnonymiseLastBorrowerDays', 0); >+ > my $patron = $builder->build_object( > { > class => 'Koha::Patrons', >@@ -1278,10 +1333,13 @@ subtest 'anonymise items_last_borrower' => sub { > $item_2->itemlost(1)->store; > $item_3->damaged(1)->store; > >- my $nb_rows = Koha::Patrons->search_patrons_to_anonymise( { before => '2010-10-12' } )->anonymise_issue_history(); >- is( $nb_rows, 4, 'anonymise_issue_history should have returned the number of checkouts anonymised'); >- > my $dbh = C4::Context->dbh; >+ my $stu = $dbh->prepare(q|UPDATE items_last_borrower set created_on = ? where itemnumber in (?, ?, ?, ?)|); >+ $stu->execute(DateTime->today(time_zone => C4::Context->tz())->add( days => -1 ), $item_1->itemnumber,$item_2->itemnumber,$item_3->itemnumber,$item_4->itemnumber); >+ >+ my $nb_rows = Koha::Patrons->anonymise_last_borrowers(); >+ is( $nb_rows, 1, 'anonymise_issue_history should have returned the number of last borrowers anonymised'); >+ > my $sth = $dbh->prepare(q|SELECT borrowernumber FROM items_last_borrower where itemnumber = ?|); > $sth->execute($item_1->itemnumber); > my ($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23260
:
92863
|
92864
|
93052
|
94858
|
94859
|
95033
|
95457
|
95458
|
95459
|
95460
|
95651
|
95698
|
95699
|
95700
|
95701
|
95769
|
95770
|
95771
|
95772
|
96791
|
97841
|
97842
|
98044
|
98053
|
98054
|
98064
|
98282
|
98349
|
98352
|
112734
|
112735
|
112736
|
112737
|
112738
|
112739
|
112740
|
112741
|
112742
|
112743
|
117974
|
117975
|
117976
|
117977
|
117978
|
117979
|
117980
|
117981
|
117982
|
117983
|
120522
|
120523
|
120524
|
120525
|
120526
|
120527
|
120528
|
120529
|
120530
|
120531
|
122963
|
122964
|
122965
|
122966
|
122967
|
122968
|
122969
|
122970
|
122971
|
122972
|
145175
|
145176
|
145177
|
145178
|
145179
|
145180
|
145181
|
145182
|
145183
|
145184
|
157106
|
157107
|
157108
|
157109
|
157110
|
157111
|
157112
|
157113
|
157114
|
157115
|
157116
|
159291
|
159292
|
159293
|
159294
|
159298
|
159299
|
159300
|
159301
|
164129
|
164130
|
164131
|
164132
|
164133