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