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