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::MockModule; |
23 |
|
24 |
|
24 |
use Koha::Account; |
25 |
use Koha::Account; |
25 |
use Koha::Account::Lines; |
26 |
use Koha::Account::Lines; |
Lines 225-227
subtest 'lines() tests' => sub {
Link Here
|
225 |
|
226 |
|
226 |
$schema->storage->txn_rollback; |
227 |
$schema->storage->txn_rollback; |
227 |
}; |
228 |
}; |
228 |
- |
229 |
|
|
|
230 |
subtest 'pay() tests' => sub { |
231 |
|
232 |
plan tests => 2; |
233 |
|
234 |
$schema->storage->txn_begin; |
235 |
|
236 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
237 |
my $library = $builder->build_object({ class => 'Koha::Libraries' }); |
238 |
my $account = $patron->account; |
239 |
|
240 |
my $context = Test::MockModule->new('C4::Context'); |
241 |
$context->mock( 'userenv', { branch => $library->id } ); |
242 |
|
243 |
my $credit_1_id = $account->pay({ amount => 200 }); |
244 |
my $credit_1 = Koha::Account::Lines->find( $credit_1_id ); |
245 |
|
246 |
is( $credit_1->branchcode, undef, 'No branchcode is set if library_id was not passed' ); |
247 |
|
248 |
my $credit_2_id = $account->pay({ amount => 150, library_id => $library->id }); |
249 |
my $credit_2 = Koha::Account::Lines->find( $credit_2_id ); |
250 |
|
251 |
is( $credit_2->branchcode, $library->id, 'branchcode set because library_id was passed' ); |
252 |
|
253 |
$schema->storage->txn_rollback; |
254 |
}; |