Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8ba1a71

Browse files
committedMay 18, 2024
simplify tests for asserting private property
1 parent 256d5e6 commit 8ba1a71

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed
 

‎tests/TokenizerTest.php

+15-3
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,23 @@
1515

1616
final class TokenizerTest extends TestCase
1717
{
18-
public function testKeywordsReservedAreUpperCasedAndWithoutWhitespace(): void
18+
/**
19+
* @param 'reserved'|'reservedToplevel'|'reservedNewline' $propertyName
20+
*
21+
* @return list<string>
22+
*/
23+
private function getTokenizerList(string $propertyName): array
1924
{
2025
$tokenizerReflClass = new ReflectionClass(Tokenizer::class);
21-
/** @var list<string> $tokenizerReserved */
22-
$tokenizerReserved = $tokenizerReflClass->getProperty('reserved')->getDefaultValue();
26+
/** @var list<string> $res */
27+
$res = $tokenizerReflClass->getProperty($propertyName)->getDefaultValue();
28+
29+
return $res;
30+
}
31+
32+
public function testKeywordsReservedAreUpperCasedAndWithoutWhitespace(): void
33+
{
34+
$tokenizerReserved = $this->getTokenizerList('reserved');
2335

2436
$kwsDiff = array_filter($tokenizerReserved, static function ($v) {
2537
return $v !== strtoupper($v) || preg_match('~\s~', $v) !== 0;

0 commit comments

Comments
 (0)
Please sign in to comment.