mapper.php

Basically a serialization wrapper for netresearch/jsonmapper
git clone git://git.finwo.net/lib/mapper.php
Log | Files | Refs | README

LintTest.php (974B)


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