예제 #1
0
 /**
  * Run tokenizer against external PHP file then compare the finder
  * results against the expected results from the text file
  *
  * Text file format:
  *
  * T_TOKEN_CONSTANT index1 index2 index3
  *
  * @dataProvider dataFind
  * @param string $inputFile
  * @param string $expectedFile
  */
 public function testFind($inputFile, $expectedFile)
 {
     $this->assertTrue(file_exists($inputFile), 'Input file missing: ' . $inputFile);
     $this->assertTrue(file_exists($expectedFile), 'Expected results file missing: ' . $expectedFile);
     $tokenizer = Tokenizer::tokenizeFile($inputFile);
     $expected = file($expectedFile);
     foreach ($expected as $line) {
         $line = trim($line);
         $expectedIndices = explode(' ', $line);
         $tokenConstantString = array_shift($expectedIndices);
         $tokenConstants = explode('|', $tokenConstantString);
         foreach ($tokenConstants as $k => $v) {
             $tokenConstants[$k] = constant($v);
             $this->assertNotNull($tokenConstants[$k], 'Unable to find constant for string: ' . $tokenConstantString);
         }
         $result = $tokenizer->findTokens($tokenConstants);
         $this->assertEquals($expectedIndices, $result);
     }
 }
예제 #2
0
function testTokenize()
{
    Tokenizer::tokenizeFile('big_file.php');
}