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