| 
      
            Lines 19-25
          
      
      
        Link Here
      
     | 
  
        
          | 19 | 
           | 
          19 | 
           | 
        
        
          | 20 | 
          use Modern::Perl;  | 
          20 | 
          use Modern::Perl;  | 
        
        
          | 21 | 
           | 
          21 | 
           | 
        
          
            
              | 22 | 
              use Test::More tests => 11;  | 
              22 | 
              use Test::More tests => 12;  | 
            
        
          | 23 | 
          use Test::Warn;  | 
          23 | 
          use Test::Warn;  | 
        
        
          | 24 | 
           | 
          24 | 
           | 
        
        
          | 25 | 
          use Koha::Authority::Types;  | 
          25 | 
          use Koha::Authority::Types;  | 
        
  
    | 
      
            Lines 127-132
          subtest 'single' => sub {
      
      
        Link Here
      
     | 
  
        
          | 127 | 
              "Warning is presented if single is used for a result with multiple rows.";  | 
          127 | 
              "Warning is presented if single is used for a result with multiple rows.";  | 
        
        
          | 128 | 
          };  | 
          128 | 
          };  | 
        
        
          | 129 | 
           | 
          129 | 
           | 
        
            
               | 
               | 
              130 | 
              subtest 'last' => sub { | 
            
            
              | 131 | 
                  plan tests => 3;  | 
            
            
              | 132 | 
                  my $builder = t::lib::TestBuilder->new;  | 
            
            
              | 133 | 
                  my $patron_1  = $builder->build( { source => 'Borrower' } ); | 
            
            
              | 134 | 
                  my $patron_2  = $builder->build( { source => 'Borrower' } ); | 
            
            
              | 135 | 
                  my $last_patron = Koha::Patrons->search->last;  | 
            
            
              | 136 | 
                  is( $last_patron->borrowernumber, $patron_2->{borrowernumber}, '->last should return the last inserted patron' ); | 
            
            
              | 137 | 
                  $last_patron = Koha::Patrons->search({ borrowernumber => $patron_1->{borrowernumber} })->last; | 
            
            
              | 138 | 
                  is( $last_patron->borrowernumber, $patron_1->{borrowernumber}, '->last should work even if there is only 1 result' ); | 
            
            
              | 139 | 
                  $last_patron = Koha::Patrons->search({ surname => 'should_not_exist' })->last; | 
            
            
              | 140 | 
                  is( $last_patron, undef, '->last should return undef if search does not return any results' );  | 
            
            
              | 141 | 
              };  | 
            
            
              | 142 | 
               | 
            
        
          | 130 | 
          subtest 'Exceptions' => sub { | 
          143 | 
          subtest 'Exceptions' => sub { | 
        
        
          | 131 | 
              plan tests => 2;  | 
          144 | 
              plan tests => 2;  | 
        
        
          | 132 | 
           | 
          145 | 
           | 
        
            
              | 133 | 
              -   | 
               | 
               |