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 63-82
subtest 'anonymize() tests' => sub {
Link Here
|
63 |
is( $@->syspref, 'AnonymousPatron', 'syspref parameter is correctly passed' ); |
82 |
is( $@->syspref, 'AnonymousPatron', 'syspref parameter is correctly passed' ); |
64 |
is( $patron->old_checkouts->count, 2, 'No changes, patron has 2 linked completed checkouts' ); |
83 |
is( $patron->old_checkouts->count, 2, 'No changes, patron has 2 linked completed checkouts' ); |
65 |
|
84 |
|
66 |
is( $checkout_1->borrowernumber, $patron->id, |
|
|
67 |
'Anonymized hold not linked to patron' ); |
68 |
is( $checkout_2->borrowernumber, $patron->id, |
85 |
is( $checkout_2->borrowernumber, $patron->id, |
69 |
'Not anonymized hold still linked to patron' ); |
86 |
'Checkout to anonymize still linked to patron' ); |
|
|
87 |
is( $checkout_2->renewals->count, 2, 'Checkout 2 has 2 renewals' ); |
70 |
|
88 |
|
71 |
my $anonymous_patron = |
89 |
my $anonymous_patron = |
72 |
$builder->build_object( { class => 'Koha::Patrons' } ); |
90 |
$builder->build_object( { class => 'Koha::Patrons' } ); |
73 |
t::lib::Mocks::mock_preference( 'AnonymousPatron', $anonymous_patron->id ); |
91 |
t::lib::Mocks::mock_preference( 'AnonymousPatron', $anonymous_patron->id ); |
74 |
|
92 |
|
75 |
# anonymize second hold |
93 |
# anonymize second checkout |
76 |
$checkout_2->anonymize; |
94 |
$checkout_2->anonymize; |
77 |
$checkout_2->discard_changes; |
95 |
$checkout_2->discard_changes; |
78 |
is( $checkout_2->borrowernumber, $anonymous_patron->id, |
96 |
is( $checkout_2->borrowernumber, $anonymous_patron->id, |
79 |
'Anonymized hold linked to anonymouspatron' ); |
97 |
'Anonymized checkout linked to anonymouspatron' ); |
|
|
98 |
is( |
99 |
$checkout_2->renewals->search( |
100 |
{ renewer_id => $anonymous_patron->id } |
101 |
)->count, |
102 |
1, |
103 |
'OPAC renewal was anonymized' |
104 |
); |
80 |
|
105 |
|
81 |
$schema->storage->txn_rollback; |
106 |
$schema->storage->txn_rollback; |
82 |
}; |
107 |
}; |