Bugzilla – Attachment 49740 Details for
Bug 10612
Add ability to delete patrons with batch patron deletion tool
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10612 - Unit tests
Bug-10612---Unit-tests.patch (text/plain), 7.27 KB, created by
Nick Clemens (kidclamp)
on 2016-03-31 15:41:17 UTC
(
hide
)
Description:
Bug 10612 - Unit tests
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2016-03-31 15:41:17 UTC
Size:
7.27 KB
patch
obsolete
>From b359c1e8e9ca39726781ba02a5462c0e96301146 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 30 Mar 2016 21:06:49 +0000 >Subject: [PATCH] Bug 10612 - Unit tests > >--- > t/db_dependent/Members.t | 130 ++++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 129 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Members.t b/t/db_dependent/Members.t >index cc89440..b590ed9 100755 >--- a/t/db_dependent/Members.t >+++ b/t/db_dependent/Members.t >@@ -17,11 +17,13 @@ > > use Modern::Perl; > >-use Test::More tests => 59; >+use Test::More tests => 76; > use Test::MockModule; > use Data::Dumper; > use C4::Context; > use Koha::Database; >+use Koha::List::Patron; >+ > > use t::lib::Mocks; > use t::lib::TestBuilder; >@@ -229,6 +231,132 @@ $borrowernumber = AddMember( %data ); > $borrower = GetMember( borrowernumber => $borrowernumber ); > is( $borrower->{userid}, $data{userid}, 'AddMember should insert the given userid' ); > >+#Regression tests for bug 10612 >+my $library3 = $builder->build({ >+ source => 'Branch', >+}); >+$builder->build({ >+ source => 'Category', >+ value => { >+ categorycode => 'STAFFER', >+ description => 'Staff dont batch del', >+ category_type => 'S', >+ }, >+}); >+ >+$builder->build({ >+ source => 'Category', >+ value => { >+ categorycode => 'CIVILIAN', >+ description => 'Civilian batch del', >+ category_type => 'A', >+ }, >+}); >+ >+$builder->build({ >+ source => 'Category', >+ value => { >+ categorycode => 'KIDclamp', >+ description => 'Kid to be guaranteed', >+ category_type => 'C', >+ }, >+}); >+ >+#$builder->clear( { source => 'Borrower' } ); >+my $borrower1 = $builder->build({ >+ source => 'Borrower', >+ value => { >+ categorycode=>'STAFFER', >+ branchcode => $library3->{branchcode}, >+ dateexpiry => '2015-01-01', >+ }, >+}); >+my $bor1inlist = $borrower1->{borrowernumber}; >+my $borrower2 = $builder->build({ >+ source => 'Borrower', >+ value => { >+ categorycode=>'STAFFER', >+ branchcode => $library3->{branchcode}, >+ dateexpiry => '2015-01-01', >+ }, >+}); >+ >+my $guarantee = $builder->build({ >+ source => 'Borrower', >+ value => { >+ categorycode=>'KIDclamp', >+ branchcode => $library3->{branchcode}, >+ dateexpiry => '2015-01-01', >+ }, >+}); >+ >+my $bor2inlist = $borrower2->{borrowernumber}; >+ >+$builder->build({ >+ source => 'OldIssue', >+ value => { >+ borrowernumber => $bor2inlist, >+ timestamp => '2016-01-01', >+ }, >+}); >+ >+my $owner = AddMember (categorycode => 'STAFFER', branchcode => $library2->{branchcode} ); >+my $list1 = AddPatronList( { name => 'Test List 1', owner => $owner } ); >+my @listpatrons = ($bor1inlist, $bor2inlist); >+AddPatronsToList( { list => $list1, borrowernumbers => \@listpatrons }); >+my $patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id() } ); >+is( scalar(@$patstodel),0,'No staff deleted from list of all staff'); >+ModMember( borrowernumber => $bor2inlist, categorycode => 'CIVILIAN' ); >+$patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id()} ); >+ok( scalar(@$patstodel)== 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted from list'); >+$patstodel = GetBorrowersToExpunge( {branchcode => $library3->{branchcode},patron_list_id => $list1->patron_list_id() } ); >+ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted by branchcode and list'); >+$patstodel = GetBorrowersToExpunge( {expired_before => '2015-01-02', patron_list_id => $list1->patron_list_id() } ); >+ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted by expirationdate and list'); >+$patstodel = GetBorrowersToExpunge( {not_borrowered_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } ); >+ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Staff patron not deleted by last issue date'); >+ >+ModMember( borrowernumber => $bor1inlist, categorycode => 'CIVILIAN' ); >+ModMember( borrowernumber => $guarantee->{borrowernumber} ,guarantorid=>$bor1inlist ); >+ >+$patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id()} ); >+ok( scalar(@$patstodel)== 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted from list'); >+$patstodel = GetBorrowersToExpunge( {branchcode => $library3->{branchcode},patron_list_id => $list1->patron_list_id() } ); >+ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted by branchcode and list'); >+$patstodel = GetBorrowersToExpunge( {expired_before => '2015-01-02', patron_list_id => $list1->patron_list_id() } ); >+ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted by expirationdate and list'); >+$patstodel = GetBorrowersToExpunge( {not_borrowered_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } ); >+ok( scalar(@$patstodel) == 1 && $patstodel->[0]->{'borrowernumber'} eq $bor2inlist,'Guarantor patron not deleted by last issue date'); >+ModMember( borrowernumber => $guarantee->{borrowernumber}, guarantorid=>'' ); >+ >+$builder->build({ >+ source => 'Issue', >+ value => { >+ borrowernumber => $bor2inlist, >+ }, >+}); >+$patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id()} ); >+is( scalar(@$patstodel),1,'Borrower with issue not deleted from list'); >+$patstodel = GetBorrowersToExpunge( {branchcode => $library3->{branchcode},patron_list_id => $list1->patron_list_id() } ); >+is( scalar(@$patstodel),1,'Borrower with issue not deleted by branchcode and list'); >+$patstodel = GetBorrowersToExpunge( {category_code => 'CIVILIAN',patron_list_id => $list1->patron_list_id() } ); >+is( scalar(@$patstodel),1,'Borrower with issue not deleted by category_code and list'); >+$patstodel = GetBorrowersToExpunge( {expired_before => '2015-01-02',patron_list_id => $list1->patron_list_id() } ); >+is( scalar(@$patstodel),1,'Borrower with issue not deleted by expiration_date and list'); >+$builder->clear( { source => 'Issue' } ); >+$patstodel = GetBorrowersToExpunge( {patron_list_id => $list1->patron_list_id()} ); >+ok( scalar(@$patstodel)== 2,'Borrowers without issue deleted from list'); >+$patstodel = GetBorrowersToExpunge( {category_code => 'CIVILIAN',patron_list_id => $list1->patron_list_id() } ); >+is( scalar(@$patstodel),2,'Borrowers without issues deleted by category_code and list'); >+$patstodel = GetBorrowersToExpunge( {expired_before => '2015-01-02',patron_list_id => $list1->patron_list_id() } ); >+is( scalar(@$patstodel),2,'Borrowers without issues deleted by expiration_date and list'); >+$patstodel = GetBorrowersToExpunge( {not_borrowered_since => '2016-01-02', patron_list_id => $list1->patron_list_id() } ); >+is( scalar(@$patstodel),2,'Borrowers without issues deleted by last issue date'); >+ >+ >+ >+ >+ > # Regression tests for BZ13502 > ## Remove all entries with userid='' (should be only 1 max) > $dbh->do(q|DELETE FROM borrowers WHERE userid = ''|); >-- >2.1.4
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 10612
:
19766
|
19767
|
21081
|
21444
|
21445
|
21446
|
22837
|
22838
|
28779
|
28780
|
36311
|
36313
|
36314
|
36315
|
41289
|
41363
|
41364
|
41365
|
46239
|
46279
|
46280
|
46834
|
47153
|
47224
|
47225
|
47226
|
47255
|
47259
|
47393
|
47394
|
47395
|
47396
|
47478
|
48833
|
48881
|
48888
|
48890
|
48891
|
48892
|
49596
|
49597
|
49607
|
49694
|
49740
|
49741
|
49766
|
49767
|
49768
|
49769
|
49770