Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 4; |
22 |
use Test::More tests => 5; |
23 |
use Test::Exception; |
23 |
use Test::Exception; |
24 |
|
24 |
|
25 |
use Koha::Account; |
25 |
use Koha::Account; |
Lines 271-273
subtest 'apply() tests' => sub {
Link Here
|
271 |
|
271 |
|
272 |
$schema->storage->txn_rollback; |
272 |
$schema->storage->txn_rollback; |
273 |
}; |
273 |
}; |
274 |
- |
274 |
|
|
|
275 |
subtest 'issue() tests' => sub { |
276 |
|
277 |
plan tests => 5; |
278 |
|
279 |
$schema->storage->txn_begin; |
280 |
|
281 |
my $library = $builder->build( { source => 'Branch' } ); |
282 |
my $patron = $builder->build( { source => 'Borrower' } ); |
283 |
my $item = $builder->build( { source => 'Item' } ); |
284 |
|
285 |
my $checkout = Koha::Checkout->new( |
286 |
{ borrowernumber => $patron->{borrowernumber}, |
287 |
itemnumber => $item->{itemnumber}, |
288 |
branchcode => $library->{branchcode}, |
289 |
})->store; |
290 |
|
291 |
my $line = Koha::Account::Line->new( |
292 |
{ |
293 |
borrowernumber => $patron->{borrowernumber}, |
294 |
itemnumber => $item->{itemnumber}, |
295 |
issue_id => $checkout->issue_id, |
296 |
accounttype => "F", |
297 |
amount => 10, |
298 |
})->store; |
299 |
|
300 |
my $line_issue = $line->issue; |
301 |
is( ref($line_issue), 'Koha::Checkout', 'Result type is correct' ); |
302 |
is( $line_issue->issue_id, $checkout->issue_id, 'Koha::Account::Line->issue should return the correct issue'); |
303 |
|
304 |
my ( $returned, undef, $old_checkout) = C4::Circulation::AddReturn( $item->{barcode} ,$library->{branchcode} ); |
305 |
is( $returned, 1, 'The item should have been returned' ); |
306 |
|
307 |
my $old_line_issue = $line->issue; |
308 |
is( ref($old_line_issue), 'Koha::Old::Checkout', 'Result type is correct' ); |
309 |
is( $old_line_issue->issue_id, $old_checkout->issue_id, 'Koha::Account::Line->issue should return the correct old_issue' ); |
310 |
|
311 |
$schema->storage->txn_rollback; |
312 |
}; |