data-tools.php

Generic set of data tools
git clone git://git.finwo.net/lib/data-tools.php
Log | Files | Refs | README

LintTest.php (974B)


      1 <?php
      2 
      3 class LintTest extends \PHPUnit_Framework_TestCase
      4 {
      5     public function testSrc()
      6     {
      7         // Main entry
      8         $fileList = glob('src/');
      9 
     10         // Loop through known files
     11         while ( $inode = array_shift($fileList) ) {
     12 
     13             // Try to iterate deeper
     14             if ( is_dir($inode) ) {
     15                 $fileList = array_merge($fileList, glob(realpath($inode).'/*'));
     16                 continue;
     17             }
     18 
     19             // If we're a PHP file
     20             if (preg_match('/^.+\.(php|inc)$/i', $inode)) {
     21                 // Run a unit test
     22                 $this->lintFile($inode);
     23             }
     24 
     25         }
     26     }
     27 
     28     private function lintFile($filename = '')
     29     {
     30         // Show progress in the terminal
     31         print('.');
     32 
     33         // And actually run the test (with proper error message)
     34         $this->assertContains('No syntax errors', exec(sprintf('php -l "%s"', $filename), $out), sprintf("%s contains syntax errors", $filename));
     35     }
     36 }