Bugzilla – Attachment 122965 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: Simplify tests
Bug-23260-Simplify-tests.patch (text/plain), 7.45 KB, created by
Nick Clemens (kidclamp)
on 2021-07-20 12:42:30 UTC
(
hide
)
Description:
Bug 23260: Simplify tests
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2021-07-20 12:42:30 UTC
Size:
7.45 KB
patch
obsolete
>From 974b40ab98a84e966b79f982274fd21942f5db12 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 29 Jan 2020 09:57:42 +0100 >Subject: [PATCH] Bug 23260: Simplify tests > >Use build_sample_item and build_object >--- > t/db_dependent/Koha/Patrons.t | 104 +++++++++++++--------------------- > 1 file changed, 38 insertions(+), 66 deletions(-) > >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index 4220bdff6b..8cdfc0df20 100755 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -1214,93 +1214,65 @@ subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub { > subtest 'anonymise items_last_borrower' => sub { > plan tests => 1; > >- # TODO create a subroutine in t::lib::Mocks >- my $anonymous = $builder->build( { source => 'Borrower', }, ); >+ my $anonymous = $builder->build_object( { class => 'Koha::Patrons', }, ); > >- t::lib::Mocks::mock_preference( 'AnonymousPatron', $anonymous->{borrowernumber} ); >+ t::lib::Mocks::mock_preference( 'AnonymousPatron', $anonymous->borrowernumber ); > t::lib::Mocks::mock_preference('StoreLastBorrower', 1); > > subtest 'withrawn, lost and damaged items' => sub { > plan tests => 5; > >- my $patron = $builder->build( >- { source => 'Borrower', >- value => { privacy => 1, } >- } >- ); >- my $item_1 = $builder->build_object( >- { class => 'Koha::Items', >- value => { >- itemlost => 0, >- withdrawn => 0, >- damaged => 0, >- }, >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { privacy => 1, } > } > ); >- my $issue_1 = $builder->build( >- { source => 'Issue', >- value => { >- borrowernumber => $patron->{borrowernumber}, >+ 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_object( >- { class => 'Koha::Items', >- value => { >- itemlost => 0, >- withdrawn => 0, >- damaged => 0, >- }, >- } >- ); >- my $issue_2 = $builder->build( >- { source => 'Issue', >- value => { >- borrowernumber => $patron->{borrowernumber}, >+ 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 $item_3 = $builder->build_object( >- { class => 'Koha::Items', >- value => { >- itemlost => 0, >- withdrawn => 0, >- damaged => 0, >- }, >- } >- ); >- my $issue_3 = $builder->build( >- { source => 'Issue', >- value => { >- borrowernumber => $patron->{borrowernumber}, >+ my $item_3 = $builder->build_sample_item; >+ my $issue_3 = $builder->build_object( >+ { >+ class => 'Koha::Checkouts', >+ value => { >+ borrowernumber => $patron->borrowernumber, > itemnumber => $item_3->itemnumber, > }, > } > ); >- my $item_4 = $builder->build_object( >- { class => 'Koha::Items', >- value => { >- itemlost => 0, >- withdrawn => 0, >- damaged => 0, >- }, >- } >- ); >- my $issue_4 = $builder->build( >- { source => 'Issue', >- value => { >- borrowernumber => $patron->{borrowernumber}, >+ my $item_4 = $builder->build_sample_item; >+ my $issue_4 = $builder->build_object( >+ { >+ class => 'Koha::Checkouts', >+ value => { >+ borrowernumber => $patron->borrowernumber, > itemnumber => $item_4->itemnumber, > }, > } > ); > >- my ( $returned_1, undef, undef ) = C4::Circulation::AddReturn( $item_1->barcode, undef, undef, dt_from_string('2010-10-11') ); >- my ( $returned_2, undef, undef ) = C4::Circulation::AddReturn( $item_2->barcode, undef, undef, dt_from_string('2010-10-11') ); >- my ( $returned_3, undef, undef ) = C4::Circulation::AddReturn( $item_3->barcode, undef, undef, dt_from_string('2010-10-11') ); >- my ( $returned_4, undef, undef ) = C4::Circulation::AddReturn( $item_4->barcode, undef, undef, dt_from_string('2010-10-11') ); >+ my ( $returned_1 ) = C4::Circulation::AddReturn( $item_1->barcode, undef, undef, dt_from_string('2010-10-11') ); >+ my ( $returned_2 ) = C4::Circulation::AddReturn( $item_2->barcode, undef, undef, dt_from_string('2010-10-11') ); >+ my ( $returned_3 ) = C4::Circulation::AddReturn( $item_3->barcode, undef, undef, dt_from_string('2010-10-11') ); >+ my ( $returned_4 ) = C4::Circulation::AddReturn( $item_4->barcode, undef, undef, dt_from_string('2010-10-11') ); > is( $returned_1 && $returned_2 && $returned_3 && $returned_4, 1, 'The items should have been returned' ); > $item_1->withdrawn(1)->store; > $item_2->itemlost(1)->store; >@@ -1312,16 +1284,16 @@ subtest 'anonymise items_last_borrower' => sub { > 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}, 'withrawn items should not be anonymised' ); >+ is( $borrowernumber_used_to_anonymised, $patron->borrowernumber, 'withrawn items should not be anonymised' ); > $sth->execute($item_2->itemnumber); > ($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; >- is( $borrowernumber_used_to_anonymised, $patron->{borrowernumber}, 'lost items should not be anonymised' ); >+ is( $borrowernumber_used_to_anonymised, $patron->borrowernumber, 'lost items should not be anonymised' ); > $sth->execute($item_3->itemnumber); > ($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; >- is( $borrowernumber_used_to_anonymised, $patron->{borrowernumber}, 'damaged items should not be anonymised' ); >+ is( $borrowernumber_used_to_anonymised, $patron->borrowernumber, 'damaged items should not be anonymised' ); > $sth->execute($item_4->itemnumber); > ($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; >- is( $borrowernumber_used_to_anonymised, $anonymous->{borrowernumber}, 'not withdrawn, lost or damaged items are anonymised' ); >+ is( $borrowernumber_used_to_anonymised, $anonymous->borrowernumber, 'not withdrawn, lost or damaged items are anonymised' ); > > }; > >-- >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