Lines 1172-1178
subtest 'search_patrons_to_anonymise' => sub {
Link Here
|
1172 |
t::lib::Mocks::mock_preference( 'AnonymousPatron', '' ); |
1172 |
t::lib::Mocks::mock_preference( 'AnonymousPatron', '' ); |
1173 |
|
1173 |
|
1174 |
subtest 'AnonymousPatron is not defined' => sub { |
1174 |
subtest 'AnonymousPatron is not defined' => sub { |
1175 |
plan tests => 3; |
1175 |
|
|
|
1176 |
plan tests => 2; |
1176 |
|
1177 |
|
1177 |
t::lib::Mocks::mock_preference('IndependentBranches', 0); |
1178 |
t::lib::Mocks::mock_preference('IndependentBranches', 0); |
1178 |
my $patron = $builder->build( |
1179 |
my $patron = $builder->build( |
Lines 1192-1213
subtest 'search_patrons_to_anonymise' => sub {
Link Here
|
1192 |
|
1193 |
|
1193 |
my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->barcode, undef, undef, dt_from_string('2010-10-10') ); |
1194 |
my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->barcode, undef, undef, dt_from_string('2010-10-10') ); |
1194 |
is( $returned, 1, 'The item should have been returned' ); |
1195 |
is( $returned, 1, 'The item should have been returned' ); |
1195 |
my $rows_affected = Koha::Old::Checkouts->search( |
1196 |
my $patrons_to_anonymize = Koha::Patrons->search_patrons_to_anonymise( { before => '2010-10-11' } ); |
1196 |
{ |
1197 |
ok( $patrons_to_anonymize->count > 0, 'search_patrons_to_anonymize' ); |
1197 |
borrowernumber => [ |
|
|
1198 |
Koha::Patrons->search_patrons_to_anonymise( |
1199 |
{ before => '2010-10-11' } |
1200 |
)->get_column('borrowernumber') |
1201 |
] |
1202 |
} |
1203 |
)->anonymize; |
1204 |
ok( $rows_affected > 0, 'AnonymiseIssueHistory should affect at least 1 row' ); |
1205 |
|
1198 |
|
1206 |
my $dbh = C4::Context->dbh; |
|
|
1207 |
my ($borrowernumber_used_to_anonymised) = $dbh->selectrow_array(q| |
1208 |
SELECT borrowernumber FROM old_issues where itemnumber = ? |
1209 |
|, undef, $item->itemnumber); |
1210 |
is( $borrowernumber_used_to_anonymised, undef, 'With AnonymousPatron is not defined, the issue should have been anonymised anyway' ); |
1211 |
Koha::Patrons->find( $patron->{borrowernumber})->delete; |
1199 |
Koha::Patrons->find( $patron->{borrowernumber})->delete; |
1212 |
}; |
1200 |
}; |
1213 |
|
1201 |
|
1214 |
- |
|
|