|
Lines 269-294
subtest 'apply() tests' => sub {
Link Here
|
| 269 |
$schema->storage->txn_rollback; |
269 |
$schema->storage->txn_rollback; |
| 270 |
}; |
270 |
}; |
| 271 |
|
271 |
|
| 272 |
subtest 'Keep account info when a patron is deleted' => sub { |
272 |
subtest 'Keep account info when related patron, staff, item or issue is deleted' => sub { |
| 273 |
|
273 |
|
| 274 |
plan tests => 2; |
274 |
plan tests => 4; |
| 275 |
|
275 |
|
| 276 |
$schema->storage->txn_begin; |
276 |
$schema->storage->txn_begin; |
| 277 |
|
277 |
|
| 278 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
278 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
|
|
279 |
my $staff = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 279 |
my $item = $builder->build_object({ class => 'Koha::Items' }); |
280 |
my $item = $builder->build_object({ class => 'Koha::Items' }); |
|
|
281 |
my $issue = $builder->build_object( |
| 282 |
{ |
| 283 |
class => 'Koha::Checkout', |
| 284 |
value => { itemnumber => $item->itemnumber } |
| 285 |
} |
| 286 |
); |
| 280 |
my $line = Koha::Account::Line->new( |
287 |
my $line = Koha::Account::Line->new( |
| 281 |
{ |
288 |
{ |
| 282 |
borrowernumber => $patron->borrowernumber, |
289 |
borrowernumber => $patron->borrowernumber, |
|
|
290 |
manager_id => $staff->borrowernumber, |
| 283 |
itemnumber => $item->itemnumber, |
291 |
itemnumber => $item->itemnumber, |
|
|
292 |
issue_id => $issue->issue_id |
| 284 |
accounttype => "F", |
293 |
accounttype => "F", |
| 285 |
amount => 10, |
294 |
amount => 10, |
| 286 |
})->store; |
295 |
})->store; |
| 287 |
|
296 |
|
|
|
297 |
$issue->delete; |
| 298 |
$line = $line->get_from_storage; |
| 299 |
is( $line->issue_id, undef, "The account line should not be deleted when the related issue is delete"); |
| 300 |
|
| 288 |
$item->delete; |
301 |
$item->delete; |
| 289 |
$line = $line->get_from_storage; |
302 |
$line = $line->get_from_storage; |
| 290 |
is( $line->itemnumber, undef, "The account line should not be deleted when the related item is delete"); |
303 |
is( $line->itemnumber, undef, "The account line should not be deleted when the related item is delete"); |
| 291 |
|
304 |
|
|
|
305 |
$staff->delete; |
| 306 |
$line = $line->get_from_storage; |
| 307 |
is( $line->manager_id, undef, "The account line should not be deleted when the related staff is delete"); |
| 308 |
|
| 292 |
$patron->delete; |
309 |
$patron->delete; |
| 293 |
$line = $line->get_from_storage; |
310 |
$line = $line->get_from_storage; |
| 294 |
is( $line->borrowernumber, undef, "The account line should not be deleted when the related patron is delete"); |
311 |
is( $line->borrowernumber, undef, "The account line should not be deleted when the related patron is delete"); |
| 295 |
- |
|
|