|
Lines 38-44
my $builder = t::lib::TestBuilder->new;
Link Here
|
| 38 |
|
38 |
|
| 39 |
subtest 'fill() tests' => sub { |
39 |
subtest 'fill() tests' => sub { |
| 40 |
|
40 |
|
| 41 |
plan tests => 11; |
41 |
plan tests => 12; |
| 42 |
|
42 |
|
| 43 |
$schema->storage->txn_begin; |
43 |
$schema->storage->txn_begin; |
| 44 |
|
44 |
|
|
Lines 164-169
subtest 'fill() tests' => sub {
Link Here
|
| 164 |
|
164 |
|
| 165 |
is( $logs->count, 0, 'HoldsLog disabled, no logs added' ); |
165 |
is( $logs->count, 0, 'HoldsLog disabled, no logs added' ); |
| 166 |
|
166 |
|
|
|
167 |
subtest 'anonymization behavior tests' => sub { |
| 168 |
|
| 169 |
plan tests => 4; |
| 170 |
|
| 171 |
# reduce the tests noise |
| 172 |
t::lib::Mocks::mock_preference( 'HoldsLog', 0 ); |
| 173 |
t::lib::Mocks::mock_preference( 'HoldFeeMode', 'not_always' ); |
| 174 |
|
| 175 |
# 0 == keep forever |
| 176 |
$patron->privacy(0)->store; |
| 177 |
my $hold = $builder->build_object( |
| 178 |
{ |
| 179 |
class => 'Koha::Holds', |
| 180 |
value => { borrowernumber => $patron->id, status => undef } |
| 181 |
} |
| 182 |
); |
| 183 |
$hold->fill(); |
| 184 |
is( Koha::Old::Holds->find( $hold->id )->borrowernumber, |
| 185 |
$patron->borrowernumber, 'Patron link is kept' ); |
| 186 |
|
| 187 |
# 1 == "default", meaning it is not protected from removal |
| 188 |
$patron->privacy(1)->store; |
| 189 |
$hold = $builder->build_object( |
| 190 |
{ |
| 191 |
class => 'Koha::Holds', |
| 192 |
value => { borrowernumber => $patron->id, status => undef } |
| 193 |
} |
| 194 |
); |
| 195 |
$hold->fill(); |
| 196 |
is( Koha::Old::Holds->find( $hold->id )->borrowernumber, |
| 197 |
$patron->borrowernumber, 'Patron link is kept' ); |
| 198 |
|
| 199 |
# 2 == delete immediately |
| 200 |
$patron->privacy(2)->store; |
| 201 |
$hold = $builder->build_object( |
| 202 |
{ |
| 203 |
class => 'Koha::Holds', |
| 204 |
value => { borrowernumber => $patron->id, status => undef } |
| 205 |
} |
| 206 |
); |
| 207 |
$hold->fill(); |
| 208 |
is( Koha::Old::Holds->find( $hold->id )->borrowernumber, |
| 209 |
undef, 'Patron link is deleted immediately' ); |
| 210 |
|
| 211 |
my $anonymous_patron = $builder->build_object({ class => 'Koha::Patrons' }); |
| 212 |
t::lib::Mocks::mock_preference( 'AnonymousPatron', $anonymous_patron->id ); |
| 213 |
|
| 214 |
$hold = $builder->build_object( |
| 215 |
{ |
| 216 |
class => 'Koha::Holds', |
| 217 |
value => { borrowernumber => $patron->id, status => undef } |
| 218 |
} |
| 219 |
); |
| 220 |
$hold->cancel(); |
| 221 |
is( |
| 222 |
Koha::Old::Holds->find( $hold->id )->borrowernumber, |
| 223 |
$anonymous_patron->id, |
| 224 |
'Patron link is set to the configured anonymous patron immediately' |
| 225 |
); |
| 226 |
}; |
| 227 |
|
| 167 |
$schema->storage->txn_rollback; |
228 |
$schema->storage->txn_rollback; |
| 168 |
}; |
229 |
}; |
| 169 |
|
230 |
|
| 170 |
- |
|
|