Lines 1213-1305
subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub {
Link Here
|
1213 |
subtest 'anonymise items_last_borrower' => sub { |
1213 |
subtest 'anonymise items_last_borrower' => sub { |
1214 |
plan tests => 1; |
1214 |
plan tests => 1; |
1215 |
|
1215 |
|
1216 |
# TODO create a subroutine in t::lib::Mocks |
1216 |
my $anonymous = $builder->build_object( { class => 'Koha::Patrons', }, ); |
1217 |
my $anonymous = $builder->build( { source => 'Borrower', }, ); |
|
|
1218 |
|
1217 |
|
1219 |
t::lib::Mocks::mock_preference( 'AnonymousPatron', $anonymous->{borrowernumber} ); |
1218 |
t::lib::Mocks::mock_preference( 'AnonymousPatron', $anonymous->borrowernumber ); |
1220 |
t::lib::Mocks::mock_preference('StoreLastBorrower', 1); |
1219 |
t::lib::Mocks::mock_preference('StoreLastBorrower', 1); |
1221 |
|
1220 |
|
1222 |
subtest 'withrawn, lost and damaged items' => sub { |
1221 |
subtest 'withrawn, lost and damaged items' => sub { |
1223 |
plan tests => 5; |
1222 |
plan tests => 5; |
1224 |
|
1223 |
|
1225 |
my $patron = $builder->build( |
1224 |
my $patron = $builder->build_object( |
1226 |
{ source => 'Borrower', |
1225 |
{ |
1227 |
value => { privacy => 1, } |
1226 |
class => 'Koha::Patrons', |
1228 |
} |
1227 |
value => { privacy => 1, } |
1229 |
); |
|
|
1230 |
my $item_1 = $builder->build_object( |
1231 |
{ class => 'Koha::Items', |
1232 |
value => { |
1233 |
itemlost => 0, |
1234 |
withdrawn => 0, |
1235 |
damaged => 0, |
1236 |
}, |
1237 |
} |
1228 |
} |
1238 |
); |
1229 |
); |
1239 |
my $issue_1 = $builder->build( |
1230 |
my $item_1 = $builder->build_sample_item; |
1240 |
{ source => 'Issue', |
1231 |
my $issue_1 = $builder->build_object( |
1241 |
value => { |
1232 |
{ |
1242 |
borrowernumber => $patron->{borrowernumber}, |
1233 |
class => 'Koha::Checkouts', |
|
|
1234 |
value => { |
1235 |
borrowernumber => $patron->borrowernumber, |
1243 |
itemnumber => $item_1->itemnumber, |
1236 |
itemnumber => $item_1->itemnumber, |
1244 |
}, |
1237 |
}, |
1245 |
} |
1238 |
} |
1246 |
); |
1239 |
); |
1247 |
my $item_2 = $builder->build_object( |
1240 |
my $item_2 = $builder->build_sample_item; |
1248 |
{ class => 'Koha::Items', |
1241 |
my $issue_2 = $builder->build_object( |
1249 |
value => { |
1242 |
{ |
1250 |
itemlost => 0, |
1243 |
class => 'Koha::Checkouts', |
1251 |
withdrawn => 0, |
1244 |
value => { |
1252 |
damaged => 0, |
1245 |
borrowernumber => $patron->borrowernumber, |
1253 |
}, |
|
|
1254 |
} |
1255 |
); |
1256 |
my $issue_2 = $builder->build( |
1257 |
{ source => 'Issue', |
1258 |
value => { |
1259 |
borrowernumber => $patron->{borrowernumber}, |
1260 |
itemnumber => $item_2->itemnumber, |
1246 |
itemnumber => $item_2->itemnumber, |
1261 |
}, |
1247 |
}, |
1262 |
} |
1248 |
} |
1263 |
); |
1249 |
); |
1264 |
my $item_3 = $builder->build_object( |
1250 |
my $item_3 = $builder->build_sample_item; |
1265 |
{ class => 'Koha::Items', |
1251 |
my $issue_3 = $builder->build_object( |
1266 |
value => { |
1252 |
{ |
1267 |
itemlost => 0, |
1253 |
class => 'Koha::Checkouts', |
1268 |
withdrawn => 0, |
1254 |
value => { |
1269 |
damaged => 0, |
1255 |
borrowernumber => $patron->borrowernumber, |
1270 |
}, |
|
|
1271 |
} |
1272 |
); |
1273 |
my $issue_3 = $builder->build( |
1274 |
{ source => 'Issue', |
1275 |
value => { |
1276 |
borrowernumber => $patron->{borrowernumber}, |
1277 |
itemnumber => $item_3->itemnumber, |
1256 |
itemnumber => $item_3->itemnumber, |
1278 |
}, |
1257 |
}, |
1279 |
} |
1258 |
} |
1280 |
); |
1259 |
); |
1281 |
my $item_4 = $builder->build_object( |
1260 |
my $item_4 = $builder->build_sample_item; |
1282 |
{ class => 'Koha::Items', |
1261 |
my $issue_4 = $builder->build_object( |
1283 |
value => { |
1262 |
{ |
1284 |
itemlost => 0, |
1263 |
class => 'Koha::Checkouts', |
1285 |
withdrawn => 0, |
1264 |
value => { |
1286 |
damaged => 0, |
1265 |
borrowernumber => $patron->borrowernumber, |
1287 |
}, |
|
|
1288 |
} |
1289 |
); |
1290 |
my $issue_4 = $builder->build( |
1291 |
{ source => 'Issue', |
1292 |
value => { |
1293 |
borrowernumber => $patron->{borrowernumber}, |
1294 |
itemnumber => $item_4->itemnumber, |
1266 |
itemnumber => $item_4->itemnumber, |
1295 |
}, |
1267 |
}, |
1296 |
} |
1268 |
} |
1297 |
); |
1269 |
); |
1298 |
|
1270 |
|
1299 |
my ( $returned_1, undef, undef ) = C4::Circulation::AddReturn( $item_1->barcode, undef, undef, dt_from_string('2010-10-11') ); |
1271 |
my ( $returned_1 ) = C4::Circulation::AddReturn( $item_1->barcode, undef, undef, dt_from_string('2010-10-11') ); |
1300 |
my ( $returned_2, undef, undef ) = C4::Circulation::AddReturn( $item_2->barcode, undef, undef, dt_from_string('2010-10-11') ); |
1272 |
my ( $returned_2 ) = C4::Circulation::AddReturn( $item_2->barcode, undef, undef, dt_from_string('2010-10-11') ); |
1301 |
my ( $returned_3, undef, undef ) = C4::Circulation::AddReturn( $item_3->barcode, undef, undef, dt_from_string('2010-10-11') ); |
1273 |
my ( $returned_3 ) = C4::Circulation::AddReturn( $item_3->barcode, undef, undef, dt_from_string('2010-10-11') ); |
1302 |
my ( $returned_4, undef, undef ) = C4::Circulation::AddReturn( $item_4->barcode, undef, undef, dt_from_string('2010-10-11') ); |
1274 |
my ( $returned_4 ) = C4::Circulation::AddReturn( $item_4->barcode, undef, undef, dt_from_string('2010-10-11') ); |
1303 |
is( $returned_1 && $returned_2 && $returned_3 && $returned_4, 1, 'The items should have been returned' ); |
1275 |
is( $returned_1 && $returned_2 && $returned_3 && $returned_4, 1, 'The items should have been returned' ); |
1304 |
$item_1->withdrawn(1)->store; |
1276 |
$item_1->withdrawn(1)->store; |
1305 |
$item_2->itemlost(1)->store; |
1277 |
$item_2->itemlost(1)->store; |
Lines 1311-1326
subtest 'anonymise items_last_borrower' => sub {
Link Here
|
1311 |
my $sth = $dbh->prepare(q|SELECT borrowernumber FROM items_last_borrower where itemnumber = ?|); |
1283 |
my $sth = $dbh->prepare(q|SELECT borrowernumber FROM items_last_borrower where itemnumber = ?|); |
1312 |
$sth->execute($item_1->itemnumber); |
1284 |
$sth->execute($item_1->itemnumber); |
1313 |
my ($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; |
1285 |
my ($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; |
1314 |
is( $borrowernumber_used_to_anonymised, $patron->{borrowernumber}, 'withrawn items should not be anonymised' ); |
1286 |
is( $borrowernumber_used_to_anonymised, $patron->borrowernumber, 'withrawn items should not be anonymised' ); |
1315 |
$sth->execute($item_2->itemnumber); |
1287 |
$sth->execute($item_2->itemnumber); |
1316 |
($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; |
1288 |
($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; |
1317 |
is( $borrowernumber_used_to_anonymised, $patron->{borrowernumber}, 'lost items should not be anonymised' ); |
1289 |
is( $borrowernumber_used_to_anonymised, $patron->borrowernumber, 'lost items should not be anonymised' ); |
1318 |
$sth->execute($item_3->itemnumber); |
1290 |
$sth->execute($item_3->itemnumber); |
1319 |
($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; |
1291 |
($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; |
1320 |
is( $borrowernumber_used_to_anonymised, $patron->{borrowernumber}, 'damaged items should not be anonymised' ); |
1292 |
is( $borrowernumber_used_to_anonymised, $patron->borrowernumber, 'damaged items should not be anonymised' ); |
1321 |
$sth->execute($item_4->itemnumber); |
1293 |
$sth->execute($item_4->itemnumber); |
1322 |
($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; |
1294 |
($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; |
1323 |
is( $borrowernumber_used_to_anonymised, $anonymous->{borrowernumber}, 'not withdrawn, lost or damaged items are anonymised' ); |
1295 |
is( $borrowernumber_used_to_anonymised, $anonymous->borrowernumber, 'not withdrawn, lost or damaged items are anonymised' ); |
1324 |
|
1296 |
|
1325 |
}; |
1297 |
}; |
1326 |
|
1298 |
|
1327 |
- |
|
|