| 
      
            Lines 1-33
          
      
      
        Link Here
      
     | 
  
        
          | 1 | 
          #!/usr/bin/perl  | 
          1 | 
          #!/usr/bin/perl  | 
        
        
          | 2 | 
          #  | 
          2 | 
          #  | 
        
        
          | 3 | 
          # Copyright 2011 MJ Ray and software.coop  | 
          3 | 
          # Copyright 2011 MJ Ray and software.coop  | 
        
          
            
              | 4 | 
              # This Koha test module is a stub!  | 
              4 | 
              #  | 
            
            
              | 5 | 
              # Add more tests here!!!  | 
              5 | 
              # This file is part of Koha.  | 
            
            
               | 
               | 
              6 | 
              #  | 
            
            
              | 7 | 
              # Koha is free software; you can redistribute it and/or modify it under the  | 
            
            
              | 8 | 
              # terms of the GNU General Public License as published by the Free Software  | 
            
            
              | 9 | 
              # Foundation; either version 3 of the License, or (at your option) any later  | 
            
            
              | 10 | 
              # version.  | 
            
            
              | 11 | 
              #  | 
            
            
              | 12 | 
              # Koha is distributed in the hope that it will be useful, but WITHOUT ANY  | 
            
            
              | 13 | 
              # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR  | 
            
            
              | 14 | 
              # A PARTICULAR PURPOSE. See the GNU General Public License for more details.  | 
            
            
              | 15 | 
              #  | 
            
            
              | 16 | 
              # You should have received a copy of the GNU General Public License along  | 
            
            
              | 17 | 
              # with Koha; if not, see <http://www.gnu.org/licenses>.  | 
            
        
          | 6 | 
           | 
          18 | 
           | 
        
        
          | 7 | 
          use Modern::Perl;  | 
          19 | 
          use Modern::Perl;  | 
        
        
          | 8 | 
          use Test::More tests => 5;  | 
          20 | 
          use Test::More tests => 5;  | 
        
        
          | 9 | 
           | 
          21 | 
           | 
        
        
          | 10 | 
          use C4::Context;  | 
          22 | 
          use C4::Context;  | 
        
            
               | 
               | 
              23 | 
              use C4::Log;  | 
            
        
          | 11 | 
          use Koha::Database;  | 
          24 | 
          use Koha::Database;  | 
        
        
          | 12 | 
          use Koha::DateUtils;  | 
          25 | 
          use Koha::DateUtils;  | 
        
        
          | 13 | 
           | 
          26 | 
           | 
        
        
          | 14 | 
          use t::lib::Mocks qw/mock_preference/; # to mock CronjobLog  | 
          27 | 
          use t::lib::Mocks qw/mock_preference/; # to mock CronjobLog  | 
        
          
            
              | 15 | 
               | 
              28 | 
              use t::lib::TestBuilder;  | 
            
            
              | 16 | 
              $| = 1;  | 
               | 
               | 
            
            
              | 17 | 
               | 
            
            
              | 18 | 
              BEGIN { | 
            
            
              | 19 | 
                  use_ok('C4::Log'); | 
            
            
              | 20 | 
              }  | 
            
            
              | 21 | 
              my $success;  | 
            
        
          | 22 | 
           | 
          29 | 
           | 
        
        
          | 23 | 
          # Make sure we can rollback.  | 
          30 | 
          # Make sure we can rollback.  | 
        
          
            
              | 24 | 
              my $schema  = Koha::Database->new->schema;  | 
              31 | 
              our $schema  = Koha::Database->new->schema;  | 
            
        
          | 25 | 
          $schema->storage->txn_begin;  | 
          32 | 
          $schema->storage->txn_begin;  | 
        
          
            
              | 26 | 
              my $dbh = C4::Context->dbh;  | 
              33 | 
              our $dbh = C4::Context->dbh;  | 
            
        
          | 27 | 
           | 
          34 | 
           | 
        
        
          | 28 | 
          subtest 'Existing tests' => sub { | 
          35 | 
          subtest 'Existing tests' => sub { | 
        
        
          | 29 | 
              plan tests => 6;  | 
          36 | 
              plan tests => 6;  | 
        
        
          | 30 | 
           | 
          37 | 
           | 
        
            
               | 
               | 
              38 | 
                  my $success;  | 
            
        
          | 31 | 
              eval { | 
          39 | 
              eval { | 
        
        
          | 32 | 
                  # FIXME: are we sure there is an member number 1?  | 
          40 | 
                  # FIXME: are we sure there is an member number 1?  | 
        
        
          | 33 | 
                  logaction("MEMBERS","MODIFY",1,"test operation"); | 
          41 | 
                  logaction("MEMBERS","MODIFY",1,"test operation"); | 
        
  
    | 
      
            Lines 155-158
          subtest 'GetLogs() respects interface filters' => sub {
      
      
        Link Here
      
     | 
  
        
          | 155 | 
              is( @{$logs}[0]->{ interface }, 'commandline', 'Interface correctly filtered (commandline)'); | 
          163 | 
              is( @{$logs}[0]->{ interface }, 'commandline', 'Interface correctly filtered (commandline)'); | 
        
        
          | 156 | 
          };  | 
          164 | 
          };  | 
        
        
          | 157 | 
           | 
          165 | 
           | 
        
            
               | 
               | 
              166 | 
              subtest 'GDPR logging' => sub { | 
            
            
              | 167 | 
                  plan tests => 1;  | 
            
            
              | 168 | 
               | 
            
            
              | 169 | 
                  my $builder = t::lib::TestBuilder->new;  | 
            
            
              | 170 | 
                  my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); | 
            
            
              | 171 | 
               | 
            
            
              | 172 | 
                  t::lib::Mocks::mock_userenv({ patron => $patron }); | 
            
            
              | 173 | 
                  logaction( 'AUTH', 'FAILURE', $patron->id, '', 'opac' );  | 
            
            
              | 174 | 
                  my $logs = GetLogs( undef, undef, $patron->id, ['AUTH'], ['FAILURE'], $patron->id );  | 
            
            
              | 175 | 
                  is( @$logs, 1, 'We should find one auth failure for this patron' );  | 
            
            
              | 176 | 
               | 
            
            
              | 177 | 
              };  | 
            
            
              | 178 | 
               | 
            
        
          | 158 | 
          $schema->storage->txn_rollback;  | 
          179 | 
          $schema->storage->txn_rollback;  | 
        
            
              | 159 | 
              -   | 
               | 
               |