Skip to content

Commit

Permalink
minor #5750 Test all const are in uppercase (SpacePossum)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 2.19 branch.

Discussion
----------

Test all const are in uppercase

Commits
-------

62c3af8 Test all const are in uppercase
  • Loading branch information
keradus committed Jun 4, 2021
2 parents 001d134 + 62c3af8 commit 8d9a5e6
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/AutoReview/ProjectCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ public function testThatSrcClassesNotExposeProperties($className)
$allowedProps = array_map(static function (\ReflectionProperty $item) {
return $item->getName();
}, $allowedProps);

$definedProps = array_map(static function (\ReflectionProperty $item) {
return $item->getName();
}, $definedProps);
Expand Down Expand Up @@ -384,12 +385,14 @@ static function (Token $token) {
return $token->isGivenKind(T_STRING);
}
);

$strings = array_map(
static function (Token $token) {
return $token->getContent();
},
$stringTokens
);

$strings = array_unique($strings);
$message = sprintf('Class %s must not use preg_*, it shall use Preg::* instead.', $className);
static::assertNotContains('preg_filter', $strings, $message);
Expand Down Expand Up @@ -588,6 +591,7 @@ static function (\ReflectionMethod $rm) {
return false !== $rm->getDocComment() && stripos($rm->getDocComment(), '@inheritdoc');
}
);

$methodsWithInheritdoc = array_map(
static function (\ReflectionMethod $rm) {
return $rm->getName();
Expand Down Expand Up @@ -742,6 +746,31 @@ public function providePhpUnitFixerExtendsAbstractPhpUnitFixerCases()
}
}

/**
* @param string $className
*
* @dataProvider provideSrcClassCases
* @dataProvider provideTestClassCases
* @requires PHP 7.1
*/
public function testConstantsAreInUpperCase($className)
{
$rc = new \ReflectionClass($className);

$reflectionClassConstants = $rc->getReflectionConstants();

if (\count($reflectionClassConstants) < 1) {
$this->addToAssertionCount(1);

return;
}

foreach ($reflectionClassConstants as $constant) {
$constantName = $constant->getName();
static::assertSame(strtoupper($constantName), $constantName, $className);
}
}

private function getUsedDataProviderMethodNames($testClassName)
{
$dataProviderMethodNames = [];
Expand Down

0 comments on commit 8d9a5e6

Please sign in to comment.