|
Lines 273-289
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 or item is deleted' => sub { |
| 277 |
|
277 |
|
| 278 |
plan tests => 2; |
278 |
plan tests => 3; |
| 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, |
| 288 |
accounttype => "F", |
296 |
accounttype => "F", |
| 289 |
amount => 10, |
297 |
amount => 10, |
|
Lines 293-298
subtest 'Keep account info when a patron is deleted' => sub {
Link Here
|
| 293 |
$line = $line->get_from_storage; |
301 |
$line = $line->get_from_storage; |
| 294 |
is( $line->itemnumber, undef, "The account line should not be deleted when the related item is delete"); |
302 |
is( $line->itemnumber, undef, "The account line should not be deleted when the related item is delete"); |
| 295 |
|
303 |
|
|
|
304 |
$staff->delete; |
| 305 |
$line = $line->get_from_storage; |
| 306 |
is( $line->manager_id, undef, "The account line should not be deleted when the related staff is delete"); |
| 307 |
|
| 296 |
$patron->delete; |
308 |
$patron->delete; |
| 297 |
$line = $line->get_from_storage; |
309 |
$line = $line->get_from_storage; |
| 298 |
is( $line->borrowernumber, undef, "The account line should not be deleted when the related patron is delete"); |
310 |
is( $line->borrowernumber, undef, "The account line should not be deleted when the related patron is delete"); |
| 299 |
- |
|
|