| Lines 19-25
          
      
      
        Link Here | 
        
          | 19 |  | 19 |  | 
        
          | 20 | use Modern::Perl; | 20 | use Modern::Perl; | 
        
          | 21 |  | 21 |  | 
          
            
              | 22 | use Test::More tests => 2; | 22 | use Test::More tests => 3; | 
        
          | 23 |  | 23 |  | 
        
          | 24 | use Koha::Account; | 24 | use Koha::Account; | 
        
          | 25 | use Koha::Account::Lines; | 25 | use Koha::Account::Lines; | 
  
    | Lines 83-88
          subtest 'outstanding_debits() tests' => sub {
      
      
        Link Here | 
        
          | 83 |     $schema->storage->txn_rollback; | 83 |     $schema->storage->txn_rollback; | 
        
          | 84 | }; | 84 | }; | 
        
          | 85 |  | 85 |  | 
            
              |  |  | 86 | subtest 'outstanding_credits() tests' => sub { | 
            
              | 87 |  | 
            
              | 88 |     plan tests => 5; | 
            
              | 89 |  | 
            
              | 90 |     $schema->storage->txn_begin; | 
            
              | 91 |  | 
            
              | 92 |     my $patron  = $builder->build_object({ class => 'Koha::Patrons' }); | 
            
              | 93 |     my $account = Koha::Account->new({ patron_id => $patron->id }); | 
            
              | 94 |  | 
            
              | 95 |     my @generated_lines; | 
            
              | 96 |     push @generated_lines, $account->add_credit({ amount => 1 }); | 
            
              | 97 |     push @generated_lines, $account->add_credit({ amount => 2 }); | 
            
              | 98 |     push @generated_lines, $account->add_credit({ amount => 3 }); | 
            
              | 99 |     push @generated_lines, $account->add_credit({ amount => 4 }); | 
            
              | 100 |  | 
            
              | 101 |     my ( $total, $lines ) = $account->outstanding_credits(); | 
            
              | 102 |  | 
            
              | 103 |     is( $total, -10, 'Outstandig debits total is correctly calculated' ); | 
            
              | 104 |  | 
            
              | 105 |     my $i = 0; | 
            
              | 106 |     foreach my $line ( @{ $lines->as_list } ) { | 
            
              | 107 |         my $fetched_line = Koha::Account::Lines->find( $generated_lines[$i]->id ); | 
            
              | 108 |         is_deeply( $line->unblessed, $fetched_line->unblessed, "Fetched line matches the generated one ($i)" ); | 
            
              | 109 |         $i++; | 
            
              | 110 |     } | 
            
              | 111 |  | 
            
              | 112 |     $schema->storage->txn_rollback; | 
            
              | 113 | }; | 
            
              | 114 |  | 
        
          | 86 | subtest 'add_credit() tests' => sub { | 115 | subtest 'add_credit() tests' => sub { | 
        
          | 87 |  | 116 |  | 
        
          | 88 |     plan tests => 15; | 117 |     plan tests => 15; | 
            
              | 89 | -  |  |  |