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