|
Lines 19-25
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 6; |
22 |
use Test::More tests => 7; |
| 23 |
use Test::Exception; |
23 |
use Test::Exception; |
| 24 |
|
24 |
|
| 25 |
use Koha::Account; |
25 |
use Koha::Account; |
|
Lines 414-417
subtest 'adjust() tests' => sub {
Link Here
|
| 414 |
$schema->storage->txn_rollback; |
414 |
$schema->storage->txn_rollback; |
| 415 |
}; |
415 |
}; |
| 416 |
|
416 |
|
|
|
417 |
subtest 'issue() tests' => sub { |
| 418 |
plan tests => 6; |
| 419 |
|
| 420 |
$schema->storage->txn_begin; |
| 421 |
|
| 422 |
my $library = $builder->build( { source => 'Branch' } ); |
| 423 |
my $patron = $builder->build( { source => 'Borrower' } ); |
| 424 |
my $item = $builder->build( { source => 'Item' } ); |
| 425 |
|
| 426 |
my $checkout = Koha::Checkout->new( |
| 427 |
{ borrowernumber => $patron->{borrowernumber}, |
| 428 |
itemnumber => $item->{itemnumber}, |
| 429 |
branchcode => $library->{branchcode}, |
| 430 |
})->store; |
| 431 |
|
| 432 |
my $line = Koha::Account::Line->new( |
| 433 |
{ |
| 434 |
borrowernumber => $patron->{borrowernumber}, |
| 435 |
itemnumber => $item->{itemnumber}, |
| 436 |
issue_id => $checkout->issue_id, |
| 437 |
accounttype => "F", |
| 438 |
amount => 10, |
| 439 |
})->store; |
| 440 |
|
| 441 |
my $line_issue = $line->issue; |
| 442 |
is( ref($line_issue), 'Koha::Checkout', 'Result type is correct' ); |
| 443 |
is( $line_issue->issue_id, $checkout->issue_id, 'Koha::Account::Line->issue should return the correct issue'); |
| 444 |
|
| 445 |
my ( $returned, undef, $old_checkout) = C4::Circulation::AddReturn( $item->{barcode} ,$library->{branchcode} ); |
| 446 |
is( $returned, 1, 'The item should have been returned' ); |
| 447 |
|
| 448 |
my $old_line_issue = $line->issue; |
| 449 |
is( ref($old_line_issue), 'Koha::Old::Checkout', 'Result type is correct' ); |
| 450 |
is( $old_line_issue->issue_id, $old_checkout->issue_id, 'Koha::Account::Line->issue should return the correct old_issue' ); |
| 451 |
|
| 452 |
$line->issue_id(undef)->store; |
| 453 |
is( $line->issue, undef, 'Koha::Account::Line->issue should return undef if no issue linked' ); |
| 454 |
|
| 455 |
$schema->storage->txn_rollback; |
| 456 |
}; |
| 457 |
|
| 417 |
1; |
458 |
1; |
| 418 |
- |
|
|