/** * 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); } }
function testTokenize() { Tokenizer::tokenizeFile('big_file.php'); }