|
Lines 274-290
subtest 'apply() tests' => sub {
Link Here
|
| 274 |
$schema->storage->txn_rollback; |
274 |
$schema->storage->txn_rollback; |
| 275 |
}; |
275 |
}; |
| 276 |
|
276 |
|
| 277 |
subtest 'Keep account info when a patron is deleted' => sub { |
277 |
subtest 'Keep account info when related patron, staff or item is deleted' => sub { |
| 278 |
|
278 |
|
| 279 |
plan tests => 2; |
279 |
plan tests => 3; |
| 280 |
|
280 |
|
| 281 |
$schema->storage->txn_begin; |
281 |
$schema->storage->txn_begin; |
| 282 |
|
282 |
|
| 283 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
283 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
|
|
284 |
my $staff = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 284 |
my $item = $builder->build_object({ class => 'Koha::Items' }); |
285 |
my $item = $builder->build_object({ class => 'Koha::Items' }); |
|
|
286 |
my $issue = $builder->build_object( |
| 287 |
{ |
| 288 |
class => 'Koha::Checkout', |
| 289 |
value => { itemnumber => $item->itemnumber } |
| 290 |
} |
| 291 |
); |
| 285 |
my $line = Koha::Account::Line->new( |
292 |
my $line = Koha::Account::Line->new( |
| 286 |
{ |
293 |
{ |
| 287 |
borrowernumber => $patron->borrowernumber, |
294 |
borrowernumber => $patron->borrowernumber, |
|
|
295 |
manager_id => $staff->borrowernumber, |
| 288 |
itemnumber => $item->itemnumber, |
296 |
itemnumber => $item->itemnumber, |
| 289 |
accounttype => "F", |
297 |
accounttype => "F", |
| 290 |
amount => 10, |
298 |
amount => 10, |
|
Lines 294-299
subtest 'Keep account info when a patron is deleted' => sub {
Link Here
|
| 294 |
$line = $line->get_from_storage; |
302 |
$line = $line->get_from_storage; |
| 295 |
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"); |
| 296 |
|
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 |
|
| 297 |
$patron->delete; |
309 |
$patron->delete; |
| 298 |
$line = $line->get_from_storage; |
310 |
$line = $line->get_from_storage; |
| 299 |
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"); |
| 300 |
- |
|
|