| Lines 19-25
          
      
      
        Link Here | 
        
          | 19 |  | 19 |  | 
        
          | 20 | use Modern::Perl; | 20 | use Modern::Perl; | 
        
          | 21 |  | 21 |  | 
          
            
              | 22 | use Test::More tests => 5; | 22 | use Test::More tests => 6; | 
            
              |  |  | 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 396-398
          subtest 'reconcile_balance' => sub {
      
      
        Link Here | 
        
          | 396 |         $schema->storage->txn_rollback; | 397 |         $schema->storage->txn_rollback; | 
        
          | 397 |     }; | 398 |     }; | 
        
          | 398 | }; | 399 | }; | 
          
            
              | 399 | -  | 400 |  | 
            
              |  |  | 401 | subtest 'pay() tests' => sub { | 
            
              | 402 |  | 
            
              | 403 |     plan tests => 2; | 
            
              | 404 |  | 
            
              | 405 |     $schema->storage->txn_begin; | 
            
              | 406 |  | 
            
              | 407 |     my $patron  = $builder->build_object({ class => 'Koha::Patrons' }); | 
            
              | 408 |     my $library = $builder->build_object({ class => 'Koha::Libraries' }); | 
            
              | 409 |     my $account = $patron->account; | 
            
              | 410 |  | 
            
              | 411 |     my $context = Test::MockModule->new('C4::Context'); | 
            
              | 412 |     $context->mock( 'userenv', { branch => $library->id } ); | 
            
              | 413 |  | 
            
              | 414 |     my $credit_1_id = $account->pay({ amount => 200 }); | 
            
              | 415 |     my $credit_1    = Koha::Account::Lines->find( $credit_1_id ); | 
            
              | 416 |  | 
            
              | 417 |     is( $credit_1->branchcode, undef, 'No branchcode is set if library_id was not passed' ); | 
            
              | 418 |  | 
            
              | 419 |     my $credit_2_id = $account->pay({ amount => 150, library_id => $library->id }); | 
            
              | 420 |     my $credit_2    = Koha::Account::Lines->find( $credit_2_id ); | 
            
              | 421 |  | 
            
              | 422 |     is( $credit_2->branchcode, $library->id, 'branchcode set because library_id was passed' ); | 
            
              | 423 |  | 
            
              | 424 |     $schema->storage->txn_rollback; | 
            
              | 425 | }; |