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