|
Lines 1289-1381
subtest 'search_patrons_to_anonymise' => sub {
Link Here
|
| 1289 |
subtest 'anonymise items_last_borrower' => sub { |
1289 |
subtest 'anonymise items_last_borrower' => sub { |
| 1290 |
plan tests => 1; |
1290 |
plan tests => 1; |
| 1291 |
|
1291 |
|
| 1292 |
# TODO create a subroutine in t::lib::Mocks |
1292 |
my $anonymous = $builder->build_object( { class => 'Koha::Patrons', }, ); |
| 1293 |
my $anonymous = $builder->build( { source => 'Borrower', }, ); |
|
|
| 1294 |
|
1293 |
|
| 1295 |
t::lib::Mocks::mock_preference( 'AnonymousPatron', $anonymous->{borrowernumber} ); |
1294 |
t::lib::Mocks::mock_preference( 'AnonymousPatron', $anonymous->borrowernumber ); |
| 1296 |
t::lib::Mocks::mock_preference('StoreLastBorrower', 1); |
1295 |
t::lib::Mocks::mock_preference('StoreLastBorrower', 1); |
| 1297 |
|
1296 |
|
| 1298 |
subtest 'withrawn, lost and damaged items' => sub { |
1297 |
subtest 'withrawn, lost and damaged items' => sub { |
| 1299 |
plan tests => 5; |
1298 |
plan tests => 5; |
| 1300 |
|
1299 |
|
| 1301 |
my $patron = $builder->build( |
1300 |
my $patron = $builder->build_object( |
| 1302 |
{ source => 'Borrower', |
1301 |
{ |
| 1303 |
value => { privacy => 1, } |
1302 |
class => 'Koha::Patrons', |
| 1304 |
} |
1303 |
value => { privacy => 1, } |
| 1305 |
); |
|
|
| 1306 |
my $item_1 = $builder->build_object( |
| 1307 |
{ class => 'Koha::Items', |
| 1308 |
value => { |
| 1309 |
itemlost => 0, |
| 1310 |
withdrawn => 0, |
| 1311 |
damaged => 0, |
| 1312 |
}, |
| 1313 |
} |
1304 |
} |
| 1314 |
); |
1305 |
); |
| 1315 |
my $issue_1 = $builder->build( |
1306 |
my $item_1 = $builder->build_sample_item; |
| 1316 |
{ source => 'Issue', |
1307 |
my $issue_1 = $builder->build_object( |
| 1317 |
value => { |
1308 |
{ |
| 1318 |
borrowernumber => $patron->{borrowernumber}, |
1309 |
class => 'Koha::Checkouts', |
|
|
1310 |
value => { |
| 1311 |
borrowernumber => $patron->borrowernumber, |
| 1319 |
itemnumber => $item_1->itemnumber, |
1312 |
itemnumber => $item_1->itemnumber, |
| 1320 |
}, |
1313 |
}, |
| 1321 |
} |
1314 |
} |
| 1322 |
); |
1315 |
); |
| 1323 |
my $item_2 = $builder->build_object( |
1316 |
my $item_2 = $builder->build_sample_item; |
| 1324 |
{ class => 'Koha::Items', |
1317 |
my $issue_2 = $builder->build_object( |
| 1325 |
value => { |
1318 |
{ |
| 1326 |
itemlost => 0, |
1319 |
class => 'Koha::Checkouts', |
| 1327 |
withdrawn => 0, |
1320 |
value => { |
| 1328 |
damaged => 0, |
1321 |
borrowernumber => $patron->borrowernumber, |
| 1329 |
}, |
|
|
| 1330 |
} |
| 1331 |
); |
| 1332 |
my $issue_2 = $builder->build( |
| 1333 |
{ source => 'Issue', |
| 1334 |
value => { |
| 1335 |
borrowernumber => $patron->{borrowernumber}, |
| 1336 |
itemnumber => $item_2->itemnumber, |
1322 |
itemnumber => $item_2->itemnumber, |
| 1337 |
}, |
1323 |
}, |
| 1338 |
} |
1324 |
} |
| 1339 |
); |
1325 |
); |
| 1340 |
my $item_3 = $builder->build_object( |
1326 |
my $item_3 = $builder->build_sample_item; |
| 1341 |
{ class => 'Koha::Items', |
1327 |
my $issue_3 = $builder->build_object( |
| 1342 |
value => { |
1328 |
{ |
| 1343 |
itemlost => 0, |
1329 |
class => 'Koha::Checkouts', |
| 1344 |
withdrawn => 0, |
1330 |
value => { |
| 1345 |
damaged => 0, |
1331 |
borrowernumber => $patron->borrowernumber, |
| 1346 |
}, |
|
|
| 1347 |
} |
| 1348 |
); |
| 1349 |
my $issue_3 = $builder->build( |
| 1350 |
{ source => 'Issue', |
| 1351 |
value => { |
| 1352 |
borrowernumber => $patron->{borrowernumber}, |
| 1353 |
itemnumber => $item_3->itemnumber, |
1332 |
itemnumber => $item_3->itemnumber, |
| 1354 |
}, |
1333 |
}, |
| 1355 |
} |
1334 |
} |
| 1356 |
); |
1335 |
); |
| 1357 |
my $item_4 = $builder->build_object( |
1336 |
my $item_4 = $builder->build_sample_item; |
| 1358 |
{ class => 'Koha::Items', |
1337 |
my $issue_4 = $builder->build_object( |
| 1359 |
value => { |
1338 |
{ |
| 1360 |
itemlost => 0, |
1339 |
class => 'Koha::Checkouts', |
| 1361 |
withdrawn => 0, |
1340 |
value => { |
| 1362 |
damaged => 0, |
1341 |
borrowernumber => $patron->borrowernumber, |
| 1363 |
}, |
|
|
| 1364 |
} |
| 1365 |
); |
| 1366 |
my $issue_4 = $builder->build( |
| 1367 |
{ source => 'Issue', |
| 1368 |
value => { |
| 1369 |
borrowernumber => $patron->{borrowernumber}, |
| 1370 |
itemnumber => $item_4->itemnumber, |
1342 |
itemnumber => $item_4->itemnumber, |
| 1371 |
}, |
1343 |
}, |
| 1372 |
} |
1344 |
} |
| 1373 |
); |
1345 |
); |
| 1374 |
|
1346 |
|
| 1375 |
my ( $returned_1, undef, undef ) = C4::Circulation::AddReturn( $item_1->barcode, undef, undef, dt_from_string('2010-10-11') ); |
1347 |
my ( $returned_1 ) = C4::Circulation::AddReturn( $item_1->barcode, undef, undef, dt_from_string('2010-10-11') ); |
| 1376 |
my ( $returned_2, undef, undef ) = C4::Circulation::AddReturn( $item_2->barcode, undef, undef, dt_from_string('2010-10-11') ); |
1348 |
my ( $returned_2 ) = C4::Circulation::AddReturn( $item_2->barcode, undef, undef, dt_from_string('2010-10-11') ); |
| 1377 |
my ( $returned_3, undef, undef ) = C4::Circulation::AddReturn( $item_3->barcode, undef, undef, dt_from_string('2010-10-11') ); |
1349 |
my ( $returned_3 ) = C4::Circulation::AddReturn( $item_3->barcode, undef, undef, dt_from_string('2010-10-11') ); |
| 1378 |
my ( $returned_4, undef, undef ) = C4::Circulation::AddReturn( $item_4->barcode, undef, undef, dt_from_string('2010-10-11') ); |
1350 |
my ( $returned_4 ) = C4::Circulation::AddReturn( $item_4->barcode, undef, undef, dt_from_string('2010-10-11') ); |
| 1379 |
is( $returned_1 && $returned_2 && $returned_3 && $returned_4, 1, 'The items should have been returned' ); |
1351 |
is( $returned_1 && $returned_2 && $returned_3 && $returned_4, 1, 'The items should have been returned' ); |
| 1380 |
$item_1->withdrawn(1)->store; |
1352 |
$item_1->withdrawn(1)->store; |
| 1381 |
$item_2->itemlost(1)->store; |
1353 |
$item_2->itemlost(1)->store; |
|
Lines 1387-1402
subtest 'anonymise items_last_borrower' => sub {
Link Here
|
| 1387 |
my $sth = $dbh->prepare(q|SELECT borrowernumber FROM items_last_borrower where itemnumber = ?|); |
1359 |
my $sth = $dbh->prepare(q|SELECT borrowernumber FROM items_last_borrower where itemnumber = ?|); |
| 1388 |
$sth->execute($item_1->itemnumber); |
1360 |
$sth->execute($item_1->itemnumber); |
| 1389 |
my ($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; |
1361 |
my ($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; |
| 1390 |
is( $borrowernumber_used_to_anonymised, $patron->{borrowernumber}, 'withrawn items should not be anonymised' ); |
1362 |
is( $borrowernumber_used_to_anonymised, $patron->borrowernumber, 'withrawn items should not be anonymised' ); |
| 1391 |
$sth->execute($item_2->itemnumber); |
1363 |
$sth->execute($item_2->itemnumber); |
| 1392 |
($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; |
1364 |
($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; |
| 1393 |
is( $borrowernumber_used_to_anonymised, $patron->{borrowernumber}, 'lost items should not be anonymised' ); |
1365 |
is( $borrowernumber_used_to_anonymised, $patron->borrowernumber, 'lost items should not be anonymised' ); |
| 1394 |
$sth->execute($item_3->itemnumber); |
1366 |
$sth->execute($item_3->itemnumber); |
| 1395 |
($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; |
1367 |
($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; |
| 1396 |
is( $borrowernumber_used_to_anonymised, $patron->{borrowernumber}, 'damaged items should not be anonymised' ); |
1368 |
is( $borrowernumber_used_to_anonymised, $patron->borrowernumber, 'damaged items should not be anonymised' ); |
| 1397 |
$sth->execute($item_4->itemnumber); |
1369 |
$sth->execute($item_4->itemnumber); |
| 1398 |
($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; |
1370 |
($borrowernumber_used_to_anonymised) = $sth->fetchrow_array; |
| 1399 |
is( $borrowernumber_used_to_anonymised, $anonymous->{borrowernumber}, 'not withdrawn, lost or damaged items are anonymised' ); |
1371 |
is( $borrowernumber_used_to_anonymised, $anonymous->borrowernumber, 'not withdrawn, lost or damaged items are anonymised' ); |
| 1400 |
|
1372 |
|
| 1401 |
}; |
1373 |
}; |
| 1402 |
|
1374 |
|
| 1403 |
- |
|
|