Bugzilla – Attachment 57925 Details for
Bug 16966
Koha::Patrons - Move GetBorrowersWithIssuesHistoryOlderThan to search_patrons_to_anonymise
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16966: Koha::Patrons - Move AnonymiseIssueHistory tests
Bug-16966-KohaPatrons---Move-AnonymiseIssueHistory.patch (text/plain), 24.48 KB, created by
Kyle M Hall (khall)
on 2016-12-02 15:01:07 UTC
(
hide
)
Description:
Bug 16966: Koha::Patrons - Move AnonymiseIssueHistory tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-12-02 15:01:07 UTC
Size:
24.48 KB
patch
obsolete
>From 0269c6c174fbf15059128cc3b19fbca5619b91cb Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 22 Jul 2016 16:43:56 +0100 >Subject: [PATCH] Bug 16966: Koha::Patrons - Move AnonymiseIssueHistory tests > >The next patch will move C4::Circulation::AnonymiseIssueHistory and >C4::Members::GetBorrowersWithIssuesHistoryOlderThan to Koha::Patrons >This patch move the history anonymisation code to the Patrons.t test >file and the entire subtest related to StoreLastBorrower to >StoreLastBorrower.t > >It just moves and add some minor adjustements. > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/db_dependent/Circulation/AnonymiseIssueHistory.t | 313 --------------------- > t/db_dependent/Circulation/StoreLastBorrower.t | 144 ++++++++++ > t/db_dependent/Koha/Patrons.t | 178 +++++++++++- > 3 files changed, 321 insertions(+), 314 deletions(-) > delete mode 100644 t/db_dependent/Circulation/AnonymiseIssueHistory.t > create mode 100644 t/db_dependent/Circulation/StoreLastBorrower.t > >diff --git a/t/db_dependent/Circulation/AnonymiseIssueHistory.t b/t/db_dependent/Circulation/AnonymiseIssueHistory.t >deleted file mode 100644 >index e013abc..0000000 >--- a/t/db_dependent/Circulation/AnonymiseIssueHistory.t >+++ /dev/null >@@ -1,313 +0,0 @@ >- >-#!/usr/bin/perl >- >-# This file is part of Koha. >-# >-# Koha is free software; you can redistribute it and/or modify it >-# under the terms of the GNU General Public License as published by >-# the Free Software Foundation; either version 3 of the License, or >-# (at your option) any later version. >-# >-# Koha is distributed in the hope that it will be useful, but >-# WITHOUT ANY WARRANTY; without even the implied warranty of >-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >-# GNU General Public License for more details. >-# >-# You should have received a copy of the GNU General Public License >-# along with Koha; if not, see <http://www.gnu.org/licenses>. >- >-use Modern::Perl; >- >-use Test::More tests => 5; >- >-use C4::Context; >-use C4::Circulation; >- >-use Koha::Database; >-use Koha::Items; >- >-use t::lib::Mocks; >-use t::lib::TestBuilder; >- >-my $schema = Koha::Database->new->schema; >-$schema->storage->txn_begin; >- >-my $builder = t::lib::TestBuilder->new; >- >-# TODO create a subroutine in t::lib::Mocks >-my $branch = $builder->build({ source => 'Branch' }); >-my $userenv_patron = $builder->build({ >- source => 'Borrower', >- value => { branchcode => $branch->{branchcode} }, >-}); >-C4::Context->_new_userenv('DUMMY SESSION'); >-C4::Context->set_userenv( >- $userenv_patron->{borrowernumber}, >- $userenv_patron->{userid}, >- 'usercnum', 'First name', 'Surname', >- $branch->{branchcode}, >- $branch->{branchname}, >- 0, >-); >- >-my $anonymous = $builder->build( { source => 'Borrower', }, ); >- >-t::lib::Mocks::mock_preference( 'AnonymousPatron', $anonymous->{borrowernumber} ); >- >-subtest 'patron privacy is 1 (default)' => sub { >- plan tests => 4; >- t::lib::Mocks::mock_preference('IndependentBranches', 0); >- my $patron = $builder->build( >- { source => 'Borrower', >- value => { privacy => 1, branchcode => $userenv_patron->{branchcode} } >- } >- ); >- my $item = $builder->build( >- { source => 'Item', >- value => { >- itemlost => 0, >- withdrawn => 0, >- }, >- } >- ); >- my $issue = $builder->build( >- { source => 'Issue', >- value => { >- borrowernumber => $patron->{borrowernumber}, >- itemnumber => $item->{itemnumber}, >- }, >- } >- ); >- >- my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' ); >- is( $returned, 1, 'The item should have been returned' ); >- my ( $rows_affected, $err ) = C4::Circulation::AnonymiseIssueHistory('2010-10-11'); >- ok( $rows_affected > 0, 'AnonymiseIssueHistory should affect at least 1 row' ); >- is( $err, undef, 'AnonymiseIssueHistory should not return any error if success' ); >- >- 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, $anonymous->{borrowernumber}, 'With privacy=1, the issue should have been anonymised' ); >- >-}; >- >-subtest 'patron privacy is 0 (forever)' => sub { >- plan tests => 3; >- t::lib::Mocks::mock_preference('IndependentBranches', 0); >- >- my $patron = $builder->build( >- { source => 'Borrower', >- value => { privacy => 0, branchcode => $userenv_patron->{branchcode} } >- } >- ); >- my $item = $builder->build( >- { source => 'Item', >- value => { >- itemlost => 0, >- withdrawn => 0, >- }, >- } >- ); >- my $issue = $builder->build( >- { source => 'Issue', >- value => { >- borrowernumber => $patron->{borrowernumber}, >- itemnumber => $item->{itemnumber}, >- }, >- } >- ); >- >- my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' ); >- is( $returned, 1, 'The item should have been returned' ); >- my ( $rows_affected, $err ) = C4::Circulation::AnonymiseIssueHistory('2010-10-11'); >- is( $err, undef, 'AnonymiseIssueHistory should not return any error if success' ); >- >- 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, $patron->{borrowernumber}, 'With privacy=0, the issue should not be anonymised' ); >-}; >- >-t::lib::Mocks::mock_preference( 'AnonymousPatron', '' ); >- >-subtest 'AnonymousPatron is not defined' => sub { >- plan tests => 4; >- t::lib::Mocks::mock_preference('IndependentBranches', 0); >- my $patron = $builder->build( >- { source => 'Borrower', >- value => { privacy => 1, branchcode => $userenv_patron->{branchcode} } >- } >- ); >- my $item = $builder->build( >- { source => 'Item', >- value => { >- itemlost => 0, >- withdrawn => 0, >- }, >- } >- ); >- my $issue = $builder->build( >- { source => 'Issue', >- value => { >- borrowernumber => $patron->{borrowernumber}, >- itemnumber => $item->{itemnumber}, >- }, >- } >- ); >- >- my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' ); >- is( $returned, 1, 'The item should have been returned' ); >- my ( $rows_affected, $err ) = C4::Circulation::AnonymiseIssueHistory('2010-10-11'); >- ok( $rows_affected > 0, 'AnonymiseIssueHistory should affect at least 1 row' ); >- is( $err, undef, 'AnonymiseIssueHistory should not return any error if success' ); >- >- 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' ); >-}; >- >-subtest 'Logged in librarian is not superlibrarian & IndependentBranches' => sub { >- plan tests => 1; >- t::lib::Mocks::mock_preference('IndependentBranches', 1); >- my $patron = $builder->build( >- { source => 'Borrower', >- value => { privacy => 1 } # Another branchcode than the logged in librarian >- } >- ); >- my $item = $builder->build( >- { source => 'Item', >- value => { >- itemlost => 0, >- withdrawn => 0, >- }, >- } >- ); >- my $issue = $builder->build( >- { source => 'Issue', >- value => { >- borrowernumber => $patron->{borrowernumber}, >- itemnumber => $item->{itemnumber}, >- }, >- } >- ); >- >- my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' ); >- my $patrons_to_anonymise = C4::Members::GetBorrowersWithIssuesHistoryOlderThan( '2010-10-11' ); >- my ( $rows_affected, $err ) = C4::Circulation::AnonymiseIssueHistory('2010-10-11'); >- is( scalar(@$patrons_to_anonymise), $rows_affected, , 'AnonymiseIssueHistory should affect at least 1 row' ); >-}; >- >-subtest 'Test StoreLastBorrower' => sub { >- plan tests => 6; >- >- t::lib::Mocks::mock_preference( 'StoreLastBorrower', '1' ); >- >- my $patron = $builder->build( >- { >- source => 'Borrower', >- value => { privacy => 1, } >- } >- ); >- >- my $item = $builder->build( >- { >- source => 'Item', >- value => { >- itemlost => 0, >- withdrawn => 0, >- }, >- } >- ); >- >- my $issue = $builder->build( >- { >- source => 'Issue', >- value => { >- borrowernumber => $patron->{borrowernumber}, >- itemnumber => $item->{itemnumber}, >- }, >- } >- ); >- >- my $item_object = Koha::Items->find( $item->{itemnumber} ); >- my $patron_object = $item_object->last_returned_by(); >- is( $patron_object, undef, 'Koha::Item::last_returned_by returned undef' ); >- >- my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' ); >- >- $item_object = Koha::Items->find( $item->{itemnumber} ); >- $patron_object = $item_object->last_returned_by(); >- is( ref($patron_object), 'Koha::Patron', 'Koha::Item::last_returned_by returned Koha::Patron' ); >- >- $patron = $builder->build( >- { >- source => 'Borrower', >- value => { privacy => 1, } >- } >- ); >- >- $issue = $builder->build( >- { >- source => 'Issue', >- value => { >- borrowernumber => $patron->{borrowernumber}, >- itemnumber => $item->{itemnumber}, >- }, >- } >- ); >- >- ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' ); >- >- $item_object = Koha::Items->find( $item->{itemnumber} ); >- $patron_object = $item_object->last_returned_by(); >- is( $patron_object->id, $patron->{borrowernumber}, 'Second patron to return item replaces the first' ); >- >- $patron = $builder->build( >- { >- source => 'Borrower', >- value => { privacy => 1, } >- } >- ); >- $patron_object = Koha::Patrons->find( $patron->{borrowernumber} ); >- >- $item_object->last_returned_by($patron_object); >- $item_object = Koha::Items->find( $item->{itemnumber} ); >- my $patron_object2 = $item_object->last_returned_by(); >- is( $patron_object->id, $patron_object2->id, >- 'Calling last_returned_by with Borrower object sets last_returned_by to that borrower' ); >- >- $patron_object->delete; >- $item_object = Koha::Items->find( $item->{itemnumber} ); >- is( $item_object->last_returned_by, undef, 'last_returned_by should return undef if the last patron to return the item has been deleted' ); >- >- t::lib::Mocks::mock_preference( 'StoreLastBorrower', '0' ); >- $patron = $builder->build( >- { >- source => 'Borrower', >- value => { privacy => 1, } >- } >- ); >- >- $issue = $builder->build( >- { >- source => 'Issue', >- value => { >- borrowernumber => $patron->{borrowernumber}, >- itemnumber => $item->{itemnumber}, >- }, >- } >- ); >- ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' ); >- >- $item_object = Koha::Items->find( $item->{itemnumber} ); >- is( $item_object->last_returned_by, undef, 'Last patron to return item should not be stored if StoreLastBorrower if off' ); >-}; >- >-$schema->storage->txn_rollback; >- >-1; >diff --git a/t/db_dependent/Circulation/StoreLastBorrower.t b/t/db_dependent/Circulation/StoreLastBorrower.t >new file mode 100644 >index 0000000..7d62474 >--- /dev/null >+++ b/t/db_dependent/Circulation/StoreLastBorrower.t >@@ -0,0 +1,144 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 1; >+ >+use C4::Context; >+use C4::Circulation; >+ >+use Koha::Database; >+use Koha::Items; >+ >+use t::lib::Mocks; >+use t::lib::TestBuilder; >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+my $builder = t::lib::TestBuilder->new; >+ >+subtest 'Test StoreLastBorrower' => sub { >+ plan tests => 6; >+ >+ t::lib::Mocks::mock_preference( 'StoreLastBorrower', '1' ); >+ >+ my $patron = $builder->build( >+ { >+ source => 'Borrower', >+ value => { privacy => 1, } >+ } >+ ); >+ >+ my $item = $builder->build( >+ { >+ source => 'Item', >+ value => { >+ itemlost => 0, >+ withdrawn => 0, >+ }, >+ } >+ ); >+ >+ my $issue = $builder->build( >+ { >+ source => 'Issue', >+ value => { >+ borrowernumber => $patron->{borrowernumber}, >+ itemnumber => $item->{itemnumber}, >+ }, >+ } >+ ); >+ >+ my $item_object = Koha::Items->find( $item->{itemnumber} ); >+ my $patron_object = $item_object->last_returned_by(); >+ is( $patron_object, undef, 'Koha::Item::last_returned_by returned undef' ); >+ >+ my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, $patron->{branchcode}, undef, undef, '2010-10-10' ); >+ >+ $item_object = Koha::Items->find( $item->{itemnumber} ); >+ $patron_object = $item_object->last_returned_by(); >+ is( ref($patron_object), 'Koha::Patron', 'Koha::Item::last_returned_by returned Koha::Patron' ); >+ >+ $patron = $builder->build( >+ { >+ source => 'Borrower', >+ value => { privacy => 1, } >+ } >+ ); >+ >+ $issue = $builder->build( >+ { >+ source => 'Issue', >+ value => { >+ borrowernumber => $patron->{borrowernumber}, >+ itemnumber => $item->{itemnumber}, >+ }, >+ } >+ ); >+ >+ ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, $patron->{branchcode}, undef, undef, '2010-10-10' ); >+ >+ $item_object = Koha::Items->find( $item->{itemnumber} ); >+ $patron_object = $item_object->last_returned_by(); >+ is( $patron_object->id, $patron->{borrowernumber}, 'Second patron to return item replaces the first' ); >+ >+ $patron = $builder->build( >+ { >+ source => 'Borrower', >+ value => { privacy => 1, } >+ } >+ ); >+ $patron_object = Koha::Patrons->find( $patron->{borrowernumber} ); >+ >+ $item_object->last_returned_by($patron_object); >+ $item_object = Koha::Items->find( $item->{itemnumber} ); >+ my $patron_object2 = $item_object->last_returned_by(); >+ is( $patron_object->id, $patron_object2->id, >+ 'Calling last_returned_by with Borrower object sets last_returned_by to that borrower' ); >+ >+ $patron_object->delete; >+ $item_object = Koha::Items->find( $item->{itemnumber} ); >+ is( $item_object->last_returned_by, undef, 'last_returned_by should return undef if the last patron to return the item has been deleted' ); >+ >+ t::lib::Mocks::mock_preference( 'StoreLastBorrower', '0' ); >+ $patron = $builder->build( >+ { >+ source => 'Borrower', >+ value => { privacy => 1, } >+ } >+ ); >+ >+ $issue = $builder->build( >+ { >+ source => 'Issue', >+ value => { >+ borrowernumber => $patron->{borrowernumber}, >+ itemnumber => $item->{itemnumber}, >+ }, >+ } >+ ); >+ ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, $patron->{branchcode}, undef, undef, '2010-10-10' ); >+ >+ $item_object = Koha::Items->find( $item->{itemnumber} ); >+ is( $item_object->last_returned_by, undef, 'Last patron to return item should not be stored if StoreLastBorrower if off' ); >+}; >+ >+$schema->storage->txn_rollback; >+ >+1; >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index 7be731c..2c69648 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -19,10 +19,11 @@ > > use Modern::Perl; > >-use Test::More tests => 13; >+use Test::More tests => 14; > use Test::Warn; > > use C4::Members; >+use C4::Circulation; > > use Koha::Holds; > use Koha::Patron; >@@ -362,6 +363,181 @@ subtest 'add_enrolment_fee_if_needed' => sub { > $patron->delete; > }; > >+subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub { >+ plan tests => 4; >+ >+ # TODO create a subroutine in t::lib::Mocks >+ my $branch = $builder->build({ source => 'Branch' }); >+ my $userenv_patron = $builder->build({ >+ source => 'Borrower', >+ value => { branchcode => $branch->{branchcode} }, >+ }); >+ C4::Context->_new_userenv('DUMMY SESSION'); >+ C4::Context->set_userenv( >+ $userenv_patron->{borrowernumber}, >+ $userenv_patron->{userid}, >+ 'usercnum', 'First name', 'Surname', >+ $branch->{branchcode}, >+ $branch->{branchname}, >+ 0, >+ ); >+ my $anonymous = $builder->build( { source => 'Borrower', }, ); >+ >+ t::lib::Mocks::mock_preference( 'AnonymousPatron', $anonymous->{borrowernumber} ); >+ >+ subtest 'patron privacy is 1 (default)' => sub { >+ plan tests => 3; >+ >+ t::lib::Mocks::mock_preference('IndependentBranches', 0); >+ my $patron = $builder->build( >+ { source => 'Borrower', >+ value => { privacy => 1, } >+ } >+ ); >+ my $item = $builder->build( >+ { source => 'Item', >+ value => { >+ itemlost => 0, >+ withdrawn => 0, >+ }, >+ } >+ ); >+ my $issue = $builder->build( >+ { source => 'Issue', >+ value => { >+ borrowernumber => $patron->{borrowernumber}, >+ itemnumber => $item->{itemnumber}, >+ }, >+ } >+ ); >+ >+ my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' ); >+ is( $returned, 1, 'The item should have been returned' ); >+ my $rows_affected = Koha::Patrons->search_patrons_to_anonymise( '2010-10-11')->anonymise_issue_history('2010-10-11'); >+ ok( $rows_affected > 0, 'AnonymiseIssueHistory should affect at least 1 row' ); >+ >+ 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, $anonymous->{borrowernumber}, 'With privacy=1, the issue should have been anonymised' ); >+ Koha::Patrons->find( $patron->{borrowernumber})->delete; >+ }; >+ >+ subtest 'patron privacy is 0 (forever)' => sub { >+ plan tests => 3; >+ >+ t::lib::Mocks::mock_preference('IndependentBranches', 0); >+ my $patron = $builder->build( >+ { source => 'Borrower', >+ value => { privacy => 0, } >+ } >+ ); >+ my $item = $builder->build( >+ { source => 'Item', >+ value => { >+ itemlost => 0, >+ withdrawn => 0, >+ }, >+ } >+ ); >+ my $issue = $builder->build( >+ { source => 'Issue', >+ value => { >+ borrowernumber => $patron->{borrowernumber}, >+ itemnumber => $item->{itemnumber}, >+ }, >+ } >+ ); >+ >+ my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' ); >+ is( $returned, 1, 'The item should have been returned' ); >+ my $rows_affected = Koha::Patrons->search_patrons_to_anonymise( '2010-10-11')->anonymise_issue_history('2010-10-11'); >+ ok( $rows_affected > 0, 'AnonymiseIssueHistory should not return any error if success' ); >+ >+ 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, $patron->{borrowernumber}, 'With privacy=0, the issue should not be anonymised' ); >+ Koha::Patrons->find( $patron->{borrowernumber})->delete; >+ }; >+ >+ t::lib::Mocks::mock_preference( 'AnonymousPatron', '' ); >+ >+ subtest 'AnonymousPatron is not defined' => sub { >+ plan tests => 3; >+ >+ t::lib::Mocks::mock_preference('IndependentBranches', 0); >+ my $patron = $builder->build( >+ { source => 'Borrower', >+ value => { privacy => 1, } >+ } >+ ); >+ my $item = $builder->build( >+ { source => 'Item', >+ value => { >+ itemlost => 0, >+ withdrawn => 0, >+ }, >+ } >+ ); >+ my $issue = $builder->build( >+ { source => 'Issue', >+ value => { >+ borrowernumber => $patron->{borrowernumber}, >+ itemnumber => $item->{itemnumber}, >+ }, >+ } >+ ); >+ >+ my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' ); >+ is( $returned, 1, 'The item should have been returned' ); >+ my $rows_affected = Koha::Patrons->search_patrons_to_anonymise( '2010-10-11')->anonymise_issue_history('2010-10-11'); >+ ok( $rows_affected > 0, 'AnonymiseIssueHistory should affect at least 1 row' ); >+ >+ 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; >+ }; >+ >+ subtest 'Logged in librarian is not superlibrarian & IndependentBranches' => sub { >+ plan tests => 1; >+ t::lib::Mocks::mock_preference( 'IndependentBranches', 1 ); >+ my $patron = $builder->build( >+ { source => 'Borrower', >+ value => { privacy => 1 } # Another branchcode than the logged in librarian >+ } >+ ); >+ my $item = $builder->build( >+ { source => 'Item', >+ value => { >+ itemlost => 0, >+ withdrawn => 0, >+ }, >+ } >+ ); >+ my $issue = $builder->build( >+ { source => 'Issue', >+ value => { >+ borrowernumber => $patron->{borrowernumber}, >+ itemnumber => $item->{itemnumber}, >+ }, >+ } >+ ); >+ >+ my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' ); >+ is( Koha::Patrons->search_patrons_to_anonymise( '2010-10-11')->count, 0 ); >+ Koha::Patrons->find( $patron->{borrowernumber})->delete; >+ }; >+ >+ Koha::Patrons->find( $anonymous->{borrowernumber})->delete; >+ Koha::Patrons->find( $userenv_patron->{borrowernumber})->delete; >+}; >+ > $retrieved_patron_1->delete; > is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); > >-- >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 16966
:
53658
|
53659
|
53660
|
53661
|
56376
|
56377
|
56378
|
56379
|
56639
|
56640
|
56641
|
56642
|
57170
|
57171
|
57172
|
57885
|
57886
|
57887
|
57924
|
57925
|
57926
|
58282
|
58283
|
58284
|
58285
|
58286
|
60377
|
60378
|
60379
|
60380
|
60381
|
60382
|
60648
|
60649
|
60650
|
60651
|
60652
|
60653
|
60701
|
60702
|
60703
|
60704
|
60705
|
60706
|
60707
|
60708
|
60709