Xalan271ProcessorDriver.php
Current file: C:\DATA\Viktor\Diplomka\XSLT-Benchmarking/XSLTBenchmarking/TestsRunner/Processors/Drivers/Xalan271ProcessorDriver.php
Legend: executed not executed dead code

  Coverage
  Classes Functions / Methods Lines
Total
0.00% 0 / 1
50.00% 2 / 4 CRAP
48.00% 12 / 25
Xalan271ProcessorDriver
0.00% 0 / 1
50.00% 2 / 4 20.39
48.00% 12 / 25
 isAvailable()
0.00% 0 / 1 10.75
25.00% 3 / 12
 getCommandTemplate()
0.00% 0 / 1 3.43
63.64% 7 / 11
 getFullName()
100.00% 1 / 1 1
100.00% 1 / 1
 getKernel()
100.00% 1 / 1 1
100.00% 1 / 1



       1                 : <?php                                                                                                                                      
       2                 :                                                                                                                                            
       3                 : /*                                                                                                                                         
       4                 :  * XSLT Benchmarking                                                                                                                       
       5                 :  * @link https://github.com/masicek/XSLT-Benchmarking                                                                                      
       6                 :  * @author Viktor Mašíček <viktor@masicek.net>                                                                                          
       7                 :  * @license "New" BSD License                                                                                                              
       8                 :  */                                                                                                                                        
       9                 :                                                                                                                                            
      10                 : namespace XSLTBenchmarking\TestsRunner;                                                                                                    
      11                 :                                                                                                                                            
      12                 : // @codeCoverageIgnoreStart                                                                                                                
      13                 : require_once __DIR__ . '/AProcessorDriver.php';                                                                                            
      14                 : // @codeCoverageIgnoreEnd                                                                                                                  
      15                 :                                                                                                                                            
      16                 : /**                                                                                                                                        
      17                 :  * Driver for "Xalana 2.7.1"                                                                                                               
      18                 :  *                                                                                                                                         
      19                 :  * @author Viktor Mašíček <viktor@masicek.net>                                                                                          
      20                 :  */                                                                                                                                        
      21                 : class Xalan271ProcessorDriver extends AProcessorDriver                                                                                     
      22                 : {                                                                                                                                          
      23                 :                                                                                                                                            
      24                 :                                                                                                                                            
      25                 :     /**                                                                                                                                    
      26                 :      * Return flag, if the driver is available.                                                                                            
      27                 :      *                                                                                                                                     
      28                 :      * @return bool                                                                                                                        
      29                 :      */                                                                                                                                    
      30                 :     public function isAvailable()                                                                                                          
      31                 :     {                                                                                                                                      
      32               4 :         switch (PHP_OS)                                                                                                                    
      33                 :         {                                                                                                                                  
      34               4 :             case self::OS_WIN:                                                                                                             
      35               4 :                 return TRUE;                                                                                                               
      36                 :                 break;                                                                                                                     
      37                 :                                                                                                                                            
      38               0 :             case self::OS_LINUX:                                                                                                           
      39                 :                 // java is needed                                                                                                          
      40               0 :                 exec('java -version 2>&1 | grep \'java version\' | wc -l', $output);                                                       
      41               0 :                 if ($output[0] == '0')                                                                                                     
      42               0 :                 {                                                                                                                          
      43               0 :                     return FALSE;                                                                                                          
      44                 :                 }                                                                                                                          
      45                 :                 else                                                                                                                       
      46                 :                 {                                                                                                                          
      47               0 :                     return TRUE;                                                                                                           
      48                 :                 }                                                                                                                          
      49                 :                 break;                                                                                                                     
      50                 :                                                                                                                                            
      51               0 :             default:                                                                                                                       
      52               0 :                 return FALSE;                                                                                                              
      53                 :                 break;                                                                                                                     
      54               0 :         }                                                                                                                                  
      55                 :     }                                                                                                                                      
      56                 :                                                                                                                                            
      57                 :                                                                                                                                            
      58                 :     /**                                                                                                                                    
      59                 :      * Return template of command                                                                                                          
      60                 :      *                                                                                                                                     
      61                 :      * Templates substitutions:                                                                                                            
      62                 :      * [XSLT] = path of XSLT template for transformation                                                                                   
      63                 :      * [INPUT] = path of input XML file                                                                                                    
      64                 :      * [OUTPUT] = path of generated output XML file                                                                                        
      65                 :      * [ERROR] = path of file for eventual generated error message                                                                         
      66                 :      * [LIBS] = path of directory containing XSLT processors (libraries, command-line program etc.)                                        
      67                 :      *                                                                                                                                     
      68                 :      * @return string                                                                                                                      
      69                 :      */                                                                                                                                    
      70                 :     public function getCommandTemplate()                                                                                                   
      71                 :     {                                                                                                                                      
      72               2 :         switch (PHP_OS)                                                                                                                    
      73                 :         {                                                                                                                                  
      74               2 :             case self::OS_WIN:                                                                                                             
      75               2 :                 $prefix = '"[LIBS]\Java\1.6.0_29\java.exe"';                                                                               
      76               2 :                 break;                                                                                                                     
      77                 :                                                                                                                                            
      78               0 :             case self::OS_LINUX:                                                                                                           
      79                 :                 // we assume installing java                                                                                               
      80               0 :                 $prefix = 'java';                                                                                                          
      81               0 :                 break;                                                                                                                     
      82               0 :         }                                                                                                                                  
      83                 :                                                                                                                                            
      84               2 :         $commandTemplate = $prefix . ' -jar "[PROCESSORS]\Xalan\2.7.1\xalan.jar" -XSL "[XSLT]" -IN "[INPUT]" -OUT "[OUTPUT]" 2> "[ERROR]"';
      85               2 :         $commandTemplate = str_replace('\\', DIRECTORY_SEPARATOR, $commandTemplate);                                                       
      86               2 :         return $commandTemplate;                                                                                                           
      87                 :     }                                                                                                                                      
      88                 :                                                                                                                                            
      89                 :                                                                                                                                            
      90                 :     /**                                                                                                                                    
      91                 :      * Full name of processor (with version)                                                                                               
      92                 :      *                                                                                                                                     
      93                 :      * @return string                                                                                                                      
      94                 :      */                                                                                                                                    
      95                 :     public function getFullName()                                                                                                          
      96                 :     {                                                                                                                                      
      97               3 :         return 'Xalana 2.7.1';                                                                                                             
      98                 :     }                                                                                                                                      
      99                 :                                                                                                                                            
     100                 :                                                                                                                                            
     101                 :     /**                                                                                                                                    
     102                 :      * Return name of processor kernel.                                                                                                    
     103                 :      * Available kernels are const of this class with prefix "KERNEL_"                                                                     
     104                 :      *                                                                                                                                     
     105                 :      * Examples:                                                                                                                           
     106                 :      * Saxon 6.5.5 -> Saxon                                                                                                                
     107                 :      * xsltproc -> libxslt                                                                                                                 
     108                 :      *                                                                                                                                     
     109                 :      * @return string                                                                                                                      
     110                 :      */                                                                                                                                    
     111                 :     public function getKernel()                                                                                                            
     112                 :     {                                                                                                                                      
     113               1 :         return self::KERNEL_XALAN;                                                                                                         
     114                 :     }                                                                                                                                      
     115                 :                                                                                                                                            
     116                 :                                                                                                                                            
     117                 : }                                                                                                                                          


Generated by PHP_CodeCoverage @package_version@ using PHP 5.3.6 and PHPUnit @package_version@ at Tue Jun 26 15:06:55 CEST 2012.