| 
      
            Lines 1-15
          
      
      
        Link Here
      
     | 
  
        
          | 1 | 
          #!/usr/bin/perl  | 
          1 | 
          #!/usr/bin/perl  | 
        
        
          | 2 | 
           | 
          2 | 
           | 
        
          
            
              | 3 | 
              use strict;  | 
              3 | 
              use Modern::Perl;  | 
            
            
              | 4 | 
              use warnings;  | 
               | 
               | 
            
        
          | 5 | 
           | 
          4 | 
           | 
        
          
            
              | 6 | 
              use Test::More tests => 24;  | 
              5 | 
              use Test::More tests => 28;  | 
            
        
          | 7 | 
          use File::Basename;  | 
          6 | 
          use File::Basename;  | 
        
            
               | 
               | 
              7 | 
              use File::Temp qw( tempdir );  | 
            
        
          | 8 | 
          use FindBin qw($Bin);  | 
          8 | 
          use FindBin qw($Bin);  | 
        
        
          | 9 | 
          use Archive::Extract;  | 
          9 | 
          use Archive::Extract;  | 
        
        
          | 10 | 
          use Module::Load::Conditional qw(can_load);  | 
          10 | 
          use Module::Load::Conditional qw(can_load);  | 
        
        
          | 11 | 
           | 
          11 | 
           | 
        
        
          | 12 | 
          use C4::Context;  | 
          12 | 
          use C4::Context;  | 
        
            
               | 
               | 
              13 | 
              use t::lib::Mocks;  | 
            
        
          | 13 | 
           | 
          14 | 
           | 
        
        
          | 14 | 
          BEGIN { | 
          15 | 
          BEGIN { | 
        
        
          | 15 | 
              push( @INC, dirname(__FILE__) . '/..' );  | 
          16 | 
              push( @INC, dirname(__FILE__) . '/..' );  | 
        
  
    | 
      
            Lines 60-70
          my @plugins2 = Koha::Plugins->new({ enable_plugins => 1 })->GetPlugins({
      
      
        Link Here
      
     | 
  
        
          | 60 | 
          });  | 
          61 | 
          });  | 
        
        
          | 61 | 
          isnt( scalar @plugins2, scalar @plugins, 'GetPlugins with two metadata conditions' );  | 
          62 | 
          isnt( scalar @plugins2, scalar @plugins, 'GetPlugins with two metadata conditions' );  | 
        
        
          | 62 | 
           | 
          63 | 
           | 
        
          
            
              | 63 | 
              SKIP: { | 
              64 | 
              for my $pass ( 1 .. 2 ) { | 
            
            
              | 64 | 
                  my $plugins_dir = C4::Context->config("pluginsdir"); | 
              65 | 
                  my $plugins_dir;  | 
            
            
              | 65 | 
                  skip "plugindir not set", 4 unless defined $plugins_dir;  | 
              66 | 
                  my $module_name = 'Koha::Plugin::Com::ByWaterSolutions::KitchenSink';  | 
            
            
              | 66 | 
                  skip "plugindir not writable", 4 unless -w $plugins_dir;  | 
              67 | 
                  my $pm_path = 'Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm';  | 
            
            
              | 67 | 
                  # no need to skip further tests if KitchenSink would already exist  | 
              68 | 
                  if ( $pass == 1 ) { | 
            
            
               | 
               | 
              69 | 
                      my $plugins_dir1 = tempdir( CLEANUP => 1 );  | 
            
            
              | 70 | 
                      t::lib::Mocks::mock_config('pluginsdir', $plugins_dir1); | 
            
            
              | 71 | 
                      $plugins_dir = $plugins_dir1;  | 
            
            
              | 72 | 
                      push @INC, $plugins_dir1;  | 
            
            
              | 73 | 
                  } else { | 
            
            
              | 74 | 
                      my $plugins_dir1 = tempdir( CLEANUP => 1 );  | 
            
            
              | 75 | 
                      my $plugins_dir2 = tempdir( CLEANUP => 1 );  | 
            
            
              | 76 | 
                      t::lib::Mocks::mock_config('pluginsdir', [ $plugins_dir2, $plugins_dir1 ]); | 
            
            
              | 77 | 
                      $plugins_dir = $plugins_dir2;  | 
            
            
              | 78 | 
                      pop @INC;  | 
            
            
              | 79 | 
                      push @INC, $plugins_dir2;  | 
            
            
              | 80 | 
                      push @INC, $plugins_dir1;  | 
            
            
              | 81 | 
                  }  | 
            
            
              | 82 | 
                  my $full_pm_path = $plugins_dir . '/' . $pm_path;  | 
            
        
          | 68 | 
           | 
          83 | 
           | 
        
        
          | 69 | 
              my $ae = Archive::Extract->new( archive => "$Bin/KitchenSinkPlugin.kpz", type => 'zip' );  | 
          84 | 
              my $ae = Archive::Extract->new( archive => "$Bin/KitchenSinkPlugin.kpz", type => 'zip' );  | 
        
        
          | 70 | 
              unless ( $ae->extract( to => $plugins_dir ) ) { | 
          85 | 
              unless ( $ae->extract( to => $plugins_dir ) ) { | 
        
  
    | 
      
            Lines 75-83
          SKIP: {
      
      
        Link Here
      
     | 
  
        
          | 75 | 
              my $table = $plugin->get_qualified_table_name( 'mytable' );  | 
          90 | 
              my $table = $plugin->get_qualified_table_name( 'mytable' );  | 
        
        
          | 76 | 
           | 
          91 | 
           | 
        
        
          | 77 | 
              ok( -f $plugins_dir . "/Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm", "KitchenSink plugin installed successfully" );  | 
          92 | 
              ok( -f $plugins_dir . "/Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm", "KitchenSink plugin installed successfully" );  | 
        
            
               | 
               | 
              93 | 
                  $INC{$pm_path} = $full_pm_path; # FIXME I do not really know why, but if this is moved before the $plugin constructor, it will fail with Can't locate object method "new" via package "Koha::Plugin::Com::ByWaterSolutions::KitchenSink" | 
            
        
          | 78 | 
              Koha::Plugins::Handler->delete({ class => "Koha::Plugin::Com::ByWaterSolutions::KitchenSink", enable_plugins => 1 }); | 
          94 | 
              Koha::Plugins::Handler->delete({ class => "Koha::Plugin::Com::ByWaterSolutions::KitchenSink", enable_plugins => 1 }); | 
        
        
          | 79 | 
              my $sth = C4::Context->dbh->table_info( undef, undef, $table, 'TABLE' );  | 
          95 | 
              my $sth = C4::Context->dbh->table_info( undef, undef, $table, 'TABLE' );  | 
        
        
          | 80 | 
              my $info = $sth->fetchall_arrayref;  | 
          96 | 
              my $info = $sth->fetchall_arrayref;  | 
        
        
          | 81 | 
              is( @$info, 0, "Table $table does no longer exist" );  | 
          97 | 
              is( @$info, 0, "Table $table does no longer exist" );  | 
        
          
            
              | 82 | 
                  ok( !( -f $plugins_dir . "/Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm" ), "Koha::Plugins::Handler::delete works correctly." );  | 
              98 | 
                  ok( !( -f $full_pm_path ), "Koha::Plugins::Handler::delete works correctly." );  | 
            
        
          | 83 | 
          }  | 
          99 | 
          }  | 
        
            
              | 84 | 
              -   | 
               | 
               |