Bugzilla – Attachment 118525 Details for
Bug 26517
Avoid deleting patrons with permission
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26517: Add unit test
Bug-26517-Add-unit-test.patch (text/plain), 4.87 KB, created by
Nick Clemens (kidclamp)
on 2021-03-19 12:31:53 UTC
(
hide
)
Description:
Bug 26517: Add unit test
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2021-03-19 12:31:53 UTC
Size:
4.87 KB
patch
obsolete
>From 4263239895aeddba1f655e98969a8c08b53c726a Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Thu, 24 Sep 2020 09:08:43 +0200 >Subject: [PATCH] Bug 26517: Add unit test > >Run prove t/db_dependent/Members.t > >Signed-off-by: David Nind <david@davidnind.com> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > t/db_dependent/Members.t | 64 ++++++++++++++++++++++++++++++++++++++++++++---- > 1 file changed, 59 insertions(+), 5 deletions(-) > >diff --git a/t/db_dependent/Members.t b/t/db_dependent/Members.t >index 880c21c3bf..b7a1ceea15 100755 >--- a/t/db_dependent/Members.t >+++ b/t/db_dependent/Members.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 50; >+use Test::More tests => 53; > use Test::MockModule; > use Test::Exception; > >@@ -213,6 +213,7 @@ my $borrower1 = $builder->build({ > categorycode=>'STAFFER', > branchcode => $library3->{branchcode}, > dateexpiry => '2015-01-01', >+ flags => undef, > }, > }); > my $bor1inlist = $borrower1->{borrowernumber}; >@@ -222,6 +223,7 @@ my $borrower2 = $builder->build({ > categorycode=>'STAFFER', > branchcode => $library3->{branchcode}, > dateexpiry => '2015-01-01', >+ flags => undef, > }, > }); > >@@ -231,6 +233,7 @@ my $guarantee = $builder->build({ > categorycode=>'KIDclamp', > branchcode => $library3->{branchcode}, > dateexpiry => '2015-01-01', >+ flags => undef, > }, > }); > >@@ -318,22 +321,73 @@ is( scalar(@$patstodel),2,'Borrowers without issues deleted by last issue date') > > # Test GetBorrowersToExpunge and TrackLastPatronActivity > $dbh->do(q|UPDATE borrowers SET lastseen=NULL|); >-$builder->build({ source => 'Borrower', value => { lastseen => '2016-01-01 01:01:01', categorycode => 'CIVILIAN' } } ); >-$builder->build({ source => 'Borrower', value => { lastseen => '2016-02-02 02:02:02', categorycode => 'CIVILIAN' } } ); >-$builder->build({ source => 'Borrower', value => { lastseen => '2016-03-03 03:03:03', categorycode => 'CIVILIAN' } } ); >+$builder->build({ >+ source => 'Borrower', >+ value => { >+ lastseen => '2016-01-01 01:01:01', >+ categorycode => 'CIVILIAN', >+ flags => undef, >+ } >+}); >+$builder->build({ >+ source => 'Borrower', >+ value => { >+ lastseen => '2016-02-02 02:02:02', >+ categorycode => 'CIVILIAN', >+ flags => undef, >+ } >+}); >+$builder->build({ >+ source => 'Borrower', >+ value => { >+ lastseen => '2016-03-03 03:03:03', >+ categorycode => 'CIVILIAN', >+ flags => undef, >+ } >+}); > $patstodel = GetBorrowersToExpunge( { last_seen => '1999-12-12' }); > is( scalar @$patstodel, 0, 'TrackLastPatronActivity - 0 patrons must be deleted' ); > $patstodel = GetBorrowersToExpunge( { last_seen => '2016-02-15' }); > is( scalar @$patstodel, 2, 'TrackLastPatronActivity - 2 patrons must be deleted' ); > $patstodel = GetBorrowersToExpunge( { last_seen => '2016-04-04' }); > is( scalar @$patstodel, 3, 'TrackLastPatronActivity - 3 patrons must be deleted' ); >-my $patron2 = $builder->build({ source => 'Borrower', value => { lastseen => undef } }); >+my $patron2 = $builder->build({ >+ source => 'Borrower', >+ value => { >+ lastseen => undef, >+ flags => undef, >+ } >+}); > t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '0' ); > Koha::Patrons->find( $patron2->{borrowernumber} )->track_login; > is( Koha::Patrons->find( $patron2->{borrowernumber} )->lastseen, undef, 'Lastseen should not be changed' ); > Koha::Patrons->find( $patron2->{borrowernumber} )->track_login({ force => 1 }); > isnt( Koha::Patrons->find( $patron2->{borrowernumber} )->lastseen, undef, 'Lastseen should be changed now' ); > >+# Test GetBorrowersToExpunge and regular patron with permission >+$builder->build({ >+ source => 'Category', >+ value => { >+ categorycode => 'SMALLSTAFF', >+ description => 'Small staff', >+ category_type => 'A', >+ }, >+}); >+$borrowernumber = Koha::Patron->new({ >+ categorycode => 'SMALLSTAFF', >+ branchcode => $library2->{branchcode}, >+ flags => undef, >+})->store->borrowernumber; >+$patron = Koha::Patrons->find( $borrowernumber ); >+$patstodel = GetBorrowersToExpunge( {category_code => 'SMALLSTAFF' } ); >+is( scalar @$patstodel, 1, 'Regular patron with flags=undef can be deleted' ); >+$patron->set({ flags => 0 })->store; >+$patstodel = GetBorrowersToExpunge( {category_code => 'SMALLSTAFF' } ); >+is( scalar @$patstodel, 1, 'Regular patron with flags=0 can be deleted' ); >+$patron->set({ flags => 4 })->store; >+$patstodel = GetBorrowersToExpunge( {category_code => 'SMALLSTAFF' } ); >+is( scalar @$patstodel, 0, 'Regular patron with flags>0 can not be deleted' ); >+ > # Regression tests for BZ13502 > ## Remove all entries with userid='' (should be only 1 max) > $dbh->do(q|DELETE FROM borrowers WHERE userid = ''|); >-- >2.11.0
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 26517
:
110606
|
110636
|
110637
|
110656
|
110657
|
118524
| 118525