Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 20; |
22 |
use Test::More tests => 21; |
23 |
use Test::Exception; |
23 |
use Test::Exception; |
24 |
use Test::Warn; |
24 |
use Test::Warn; |
25 |
|
25 |
|
Lines 1398-1400
subtest 'get_savings tests' => sub {
Link Here
|
1398 |
|
1398 |
|
1399 |
$schema->storage->txn_rollback; |
1399 |
$schema->storage->txn_rollback; |
1400 |
}; |
1400 |
}; |
1401 |
- |
1401 |
|
|
|
1402 |
subtest 'update privacy tests' => sub { |
1403 |
|
1404 |
plan tests => 5; |
1405 |
|
1406 |
my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { privacy => 1 } }); |
1407 |
|
1408 |
my $old_checkout = $builder->build_object({ class => 'Koha::Old::Checkouts', value => { borrowernumber => $patron->id } }); |
1409 |
|
1410 |
t::lib::Mocks::mock_preference( 'AnonymousPatron', '0' ); |
1411 |
|
1412 |
$patron->privacy(2); #set to never |
1413 |
|
1414 |
throws_ok{ $patron->store } 'Koha::Exceptions::Patron::FailedAnonymizing', 'We throw an exception when anonymizing fails'; |
1415 |
|
1416 |
$old_checkout->discard_changes; #refresh from db |
1417 |
$patron->discard_changes; |
1418 |
|
1419 |
is( $old_checkout->borrowernumber, $patron->id, "When anonymizing fails, we don't clear the checkouts"); |
1420 |
is( $patron->privacy(), 1, "When anonymizing fails, we don't chaneg the privacy"); |
1421 |
|
1422 |
my $anon_patron = $builder->build_object({ class => 'Koha::Patrons'}); |
1423 |
t::lib::Mocks::mock_preference( 'AnonymousPatron', $anon_patron->id ); |
1424 |
|
1425 |
$patron->privacy(2)->store(); #set to never |
1426 |
|
1427 |
$old_checkout->discard_changes; #refresh from db |
1428 |
$patron->discard_changes; |
1429 |
|
1430 |
is( $old_checkout->borrowernumber, $anon_patron->id, "Checkout is successfully anonymized"); |
1431 |
is( $patron->privacy(), 2, "Patron privacy is successfully updated"); |
1432 |
}; |