Skip to content

Commit

Permalink
PhpUnitNamespacedFixer - do not try to fix constant
Browse files Browse the repository at this point in the history
  • Loading branch information
kubawerlos committed May 3, 2021
1 parent db7e1f1 commit 6da4910
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Fixer/PhpUnit/PhpUnitNamespacedFixer.php
Expand Up @@ -152,6 +152,11 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens)
break;
}

$prevIndex = $tokens->getPrevMeaningfulToken($currIndex);
if ($tokens[$prevIndex]->isGivenKind(T_CONST)) {
continue;
}

$originalClass = $tokens[$currIndex]->getContent();

if (1 !== Preg::match($this->originalClassRegEx, $originalClass)) {
Expand Down
7 changes: 7 additions & 0 deletions tests/Fixer/PhpUnit/PhpUnitNamespacedFixerTest.php
Expand Up @@ -235,6 +235,13 @@ public function aaa()
echo \PHPUnit_Runner_Version::id();
',
],
[
'<?php
final class MyTest extends TestCase
{
const PHPUNIT_FOO = "foo";
}',
],
];
}

Expand Down

0 comments on commit 6da4910

Please sign in to comment.