| Lines 19-25
          
      
      
        Link Here | 
        
          | 19 |  | 19 |  | 
        
          | 20 | use Modern::Perl; | 20 | use Modern::Perl; | 
        
          | 21 |  | 21 |  | 
          
            
              | 22 | use Test::More tests => 18; | 22 | use Test::More tests => 19; | 
        
          | 23 | use Test::Exception; | 23 | use Test::Exception; | 
        
          | 24 | use Test::Warn; | 24 | use Test::Warn; | 
        
          | 25 |  | 25 |  | 
  
    | Lines 29-34
          use Koha::DateUtils qw(dt_from_string);
      
      
        Link Here | 
        
          | 29 | use Koha::ArticleRequests; | 29 | use Koha::ArticleRequests; | 
        
          | 30 | use Koha::Patrons; | 30 | use Koha::Patrons; | 
        
          | 31 | use Koha::Patron::Relationships; | 31 | use Koha::Patron::Relationships; | 
            
              |  |  | 32 | use C4::Circulation qw( AddIssue AddReturn ); | 
        
          | 32 |  | 33 |  | 
        
          | 33 | use t::lib::TestBuilder; | 34 | use t::lib::TestBuilder; | 
        
          | 34 | use t::lib::Mocks; | 35 | use t::lib::Mocks; | 
  
    | Lines 1292-1294
          subtest 'encode_secret and decoded_secret' => sub {
      
      
        Link Here | 
        
          | 1292 |  | 1293 |  | 
        
          | 1293 |     $schema->storage->txn_rollback; | 1294 |     $schema->storage->txn_rollback; | 
        
          | 1294 | }; | 1295 | }; | 
          
            
              | 1295 | -  | 1296 |  | 
            
              |  |  | 1297 | subtest 'get_savings tests' => sub { | 
            
              | 1298 |     plan tests => 2; | 
            
              | 1299 |  | 
            
              | 1300 |     $schema->storage->txn_begin; | 
            
              | 1301 |  | 
            
              | 1302 |     my $library = $builder->build_object({ class => 'Koha::Libraries' }); | 
            
              | 1303 |     my $patron = $builder->build_object({ class => 'Koha::Patrons' }, { value => { branchcode => $library->branchcode } }); | 
            
              | 1304 |  | 
            
              | 1305 |     t::lib::Mocks::mock_userenv({ patron => $patron, branchcode => $library->branchcode }); | 
            
              | 1306 |  | 
            
              | 1307 |     my $biblio1 = $builder->build_object({ class => 'Koha::Biblios' }); | 
            
              | 1308 |     my $item1 = $builder->build_object({ class => 'Koha::Items' }, { value => { biblionumber => $biblio1->biblionumber, replacementprice => '5.00', holdingbranch => $library->branchcode, homebranch => $library->branchcode } }); | 
            
              | 1309 |     my $item2 = $builder->build_object({ class => 'Koha::Items' }, { value => { biblionumber => $biblio1->biblionumber, replacementprice => '5.00', holdingbranch => $library->branchcode, homebranch => $library->branchcode } }); | 
            
              | 1310 |  | 
            
              | 1311 |     AddIssue( $patron->unblessed, $item1->barcode ); | 
            
              | 1312 |     AddIssue( $patron->unblessed, $item2->barcode ); | 
            
              | 1313 |  | 
            
              | 1314 |     my $savings = $patron->get_savings; | 
            
              | 1315 |     is( $savings, $item1->replacementprice + $item2->replacementprice, "Savings correctly calculated from current issues" ); | 
            
              | 1316 |  | 
            
              | 1317 |     AddReturn( $item2->barcode, $item2->homebranch ); | 
            
              | 1318 |  | 
            
              | 1319 |     $savings = $patron->get_savings; | 
            
              | 1320 |     is( $savings, $item1->replacementprice + $item2->replacementprice, "Savings correctly calculated from current and old issues" ); | 
            
              | 1321 |  | 
            
              | 1322 |     $schema->storage->txn_rollback; | 
            
              | 1323 | }; |