/** * This method tests that the parser does not substitute keyword tokens in * a class or object operator chain. * * @param string $sourceFile Name of the text file. * @param array(integer) $tokenTypes List of all expected token types. * * @return void * @covers stdClass * @group pdepend * @group pdepend::bugs * @group regressiontest * @dataProvider dataProviderTokenizerKeywordSubstitutionInOperatorChain */ public function testTokenizerKeywordSubstitutionInOperatorChain($sourceFile, array $tokenTypes) { $tokenizer = new PHP_Depend_Tokenizer_Internal(); $tokenizer->setSourceFile($this->createCodeResourceURI($sourceFile)); foreach ($tokenTypes as $tokenType) { $this->assertSame($tokenType, $tokenizer->next()->type); } }
/** * This method tests that the parser does not substitute keyword tokens in * a class or object operator chain. * * @param string $sourceFile Name of the text file. * @param array(integer) $tokenTypes List of all expected token types. * * @return void * @dataProvider dataProviderTokenizerKeywordSubstitutionInOperatorChain */ public function testTokenizerKeywordSubstitutionInOperatorChain($sourceFile, array $tokenTypes) { $tokenizer = new PHP_Depend_Tokenizer_Internal(); $tokenizer->setSourceFile($this->createCodeResourceURI($sourceFile)); $actual = array(); while (is_object($token = $tokenizer->next())) { $actual[] = $token->type; } self::assertEquals($tokenTypes, $actual); }
/** * testReturnsExpectedTokensForBacktickExpressionWithEmbeddedString * * @return void * @covers PHP_Depend_Tokenizer_Internal * @group pdepend * @group pdepend::tokenizer * @group unittest */ public function testReturnsExpectedTokensForBacktickExpressionWithEmbeddedString() { $tokenizer = new PHP_Depend_Tokenizer_Internal(); $tokenizer->setSourceFile(self::createCodeResourceURI('tokenizer/' . __FUNCTION__ . '.php')); $actual = array(); while (is_object($token = $tokenizer->next())) { $actual[] = array($token->type); } $expected = array(array(PHP_Depend_ConstantsI::T_OPEN_TAG), array(PHP_Depend_ConstantsI::T_BACKTICK), array(PHP_Depend_ConstantsI::T_ENCAPSED_AND_WHITESPACE), array(PHP_Depend_ConstantsI::T_VARIABLE), array(PHP_Depend_ConstantsI::T_DOUBLE_QUOTE), array(PHP_Depend_ConstantsI::T_BACKTICK), array(PHP_Depend_ConstantsI::T_SEMICOLON)); $this->assertEquals($expected, $actual); }
/** * Returns an array with the token types found in a file associated with * the currently running test. * * @return array(integer) */ private function _getTokenTypesForTest() { $tokenizer = new PHP_Depend_Tokenizer_Internal(); $tokenizer->setSourceFile(self::createCodeResourceUriForTest()); $types = array(); while (is_object($token = $tokenizer->next())) { $types[] = $token->type; } return $types; }