Lines 30-36
my $builder = t::lib::TestBuilder->new;
Link Here
|
30 |
|
30 |
|
31 |
subtest 'anonymize() tests' => sub { |
31 |
subtest 'anonymize() tests' => sub { |
32 |
|
32 |
|
33 |
plan tests => 8; |
33 |
plan tests => 9; |
34 |
|
34 |
|
35 |
$schema->storage->txn_begin; |
35 |
$schema->storage->txn_begin; |
36 |
|
36 |
|
Lines 50-55
subtest 'anonymize() tests' => sub {
Link Here
|
50 |
value => { borrowernumber => $patron->id } |
50 |
value => { borrowernumber => $patron->id } |
51 |
} |
51 |
} |
52 |
); |
52 |
); |
|
|
53 |
my $renewal_1 = $builder->build_object( |
54 |
{ |
55 |
class => 'Koha::Checkouts::Renewals', |
56 |
value => { |
57 |
checkout_id => $checkout_2->id, |
58 |
interface => 'opac', |
59 |
renewer_id => $patron->id |
60 |
} |
61 |
} |
62 |
); |
63 |
my $renewal_2 = $builder->build_object( |
64 |
{ |
65 |
class => 'Koha::Checkouts::Renewals', |
66 |
value => { |
67 |
checkout_id => $checkout_2->id, |
68 |
interface => 'intranet' |
69 |
} |
70 |
} |
71 |
); |
53 |
|
72 |
|
54 |
is( $patron->old_checkouts->count, 2, 'Patron has 2 completed checkouts' ); |
73 |
is( $patron->old_checkouts->count, 2, 'Patron has 2 completed checkouts' ); |
55 |
|
74 |
|
Lines 62-85
subtest 'anonymize() tests' => sub {
Link Here
|
62 |
is( $@->syspref, 'AnonymousPatron', 'syspref parameter is correctly passed' ); |
81 |
is( $@->syspref, 'AnonymousPatron', 'syspref parameter is correctly passed' ); |
63 |
is( $patron->old_checkouts->count, 2, 'No changes, patron has 2 linked completed checkouts' ); |
82 |
is( $patron->old_checkouts->count, 2, 'No changes, patron has 2 linked completed checkouts' ); |
64 |
|
83 |
|
65 |
is( |
|
|
66 |
$checkout_1->borrowernumber, $patron->id, |
67 |
'Anonymized hold not linked to patron' |
68 |
); |
69 |
is( |
84 |
is( |
70 |
$checkout_2->borrowernumber, $patron->id, |
85 |
$checkout_2->borrowernumber, $patron->id, |
71 |
'Not anonymized hold still linked to patron' |
86 |
'Checkout to anonymize still linked to patron' |
72 |
); |
87 |
); |
|
|
88 |
is( $checkout_2->renewals->count, 2, 'Checkout 2 has 2 renewals' ); |
73 |
|
89 |
|
74 |
my $anonymous_patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
90 |
my $anonymous_patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
75 |
t::lib::Mocks::mock_preference( 'AnonymousPatron', $anonymous_patron->id ); |
91 |
t::lib::Mocks::mock_preference( 'AnonymousPatron', $anonymous_patron->id ); |
76 |
|
92 |
|
77 |
# anonymize second hold |
93 |
# anonymize second checkout |
78 |
$checkout_2->anonymize; |
94 |
$checkout_2->anonymize; |
79 |
$checkout_2->discard_changes; |
95 |
$checkout_2->discard_changes; |
80 |
is( |
96 |
is( |
81 |
$checkout_2->borrowernumber, $anonymous_patron->id, |
97 |
$checkout_2->borrowernumber, $anonymous_patron->id, |
82 |
'Anonymized hold linked to anonymouspatron' |
98 |
'Anonymized checkout linked to anonymouspatron' |
|
|
99 |
); |
100 |
is( |
101 |
$checkout_2->renewals->search( { renewer_id => $anonymous_patron->id } )->count, |
102 |
1, |
103 |
'OPAC renewal was anonymized' |
83 |
); |
104 |
); |
84 |
|
105 |
|
85 |
$schema->storage->txn_rollback; |
106 |
$schema->storage->txn_rollback; |