From 55c2a2bfb3e2b1c1bc213411397f102c7e3d524e Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Mon, 12 Jun 2017 18:06:10 -0700 Subject: [PATCH] Make LexicalGrammarTest match ParserGrammarTest when a new test file is added --- tests/LexicalGrammarTest.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/LexicalGrammarTest.php b/tests/LexicalGrammarTest.php index 5189cead..2f0578a1 100644 --- a/tests/LexicalGrammarTest.php +++ b/tests/LexicalGrammarTest.php @@ -33,8 +33,14 @@ function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFai * @dataProvider lexicalProvider */ public function testOutputTokenClassificationAndLength($testCaseFile, $expectedTokensFile) { + $fileContents = file_get_contents($testCaseFile); + if (!file_exists($expectedTokensFile)) { + file_put_contents($expectedTokensFile, $fileContents); + exec("git add " . $expectedTokensFile); + } + $expectedTokens = str_replace("\r\n", "\n", file_get_contents($expectedTokensFile)); - $lexer = \Microsoft\PhpParser\TokenStreamProviderFactory::GetTokenStreamProvider(file_get_contents($testCaseFile)); + $lexer = \Microsoft\PhpParser\TokenStreamProviderFactory::GetTokenStreamProvider($fileContents); $GLOBALS["SHORT_TOKEN_SERIALIZE"] = true; $tokens = str_replace("\r\n", "\n", json_encode($lexer->getTokensArray(), JSON_PRETTY_PRINT)); $GLOBALS["SHORT_TOKEN_SERIALIZE"] = false;