Skip to content

Commit 4de8393

Browse files
committed
test: remove exceptions from tokens tests
1 parent 0d7c9ec commit 4de8393

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

source/components/Tests/UnusedTokensTest.php

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ class UnusedTokensTest extends TestCase
99
private const SHADOW_TOKEN = 'shadow';
1010
private const SHADOW_REQUIRED_TOKENS = ['shadow-amount', 'shadow-color'];
1111
private const TOKEN_EXCEPTIONS = self::SHADOW_REQUIRED_TOKENS;
12-
private const COMPONENT_EXCEPTIONS = ['anchormenu', 'listing', 'slider-item', 'textarea', 'Tests'];
1312

1413
/**
1514
* @testdox component utilizes all tokens declared in component.json
@@ -23,22 +22,14 @@ public function testComponentUtilizeAllTokens(string $component, string $tokenFi
2322
self::assertShadowDependenciesAreDeclared($tokens, $styleFileContents, $component);
2423
$unusedTokens = self::findUnusedTokens($tokens, $styleFileContents, self::TOKEN_EXCEPTIONS);
2524

26-
$this->assertEmpty(
27-
$unusedTokens,
28-
sprintf(
29-
"Component '%s' has declared but unused tokens in %s:%s- %s",
30-
$component,
31-
$styleFile,
32-
PHP_EOL,
33-
implode(PHP_EOL . '- ', $unusedTokens),
34-
),
35-
);
25+
$errorMessage = sprintf("Component '%s' has declared but unused tokens in %s:%s- %s", $component, $styleFile, PHP_EOL, implode(PHP_EOL . '- ', $unusedTokens));
26+
$this->assertEmpty($unusedTokens, $errorMessage);
3627
}
3728

3829
private static function assertShadowDependenciesAreDeclared(
3930
array $tokens,
4031
string $styleFileContents,
41-
string $component
32+
string $component,
4233
): void {
4334
if (!self::styleFileUsesToken($styleFileContents, self::SHADOW_TOKEN)) {
4435
return;
@@ -96,9 +87,9 @@ private static function extractTokensFromTokenFile(string $tokenFile): array
9687
public static function componentFilesProvider(): \Generator
9788
{
9889
$componentsDir = __DIR__ . '/../';
99-
$components = array_filter(scandir($componentsDir), function ($item) use ($componentsDir) {
100-
return is_dir($componentsDir . $item)
101-
&& !in_array($item, ['.', '..', ...self::COMPONENT_EXCEPTIONS], true);
90+
$componentExceptions = ['Tests']; // Exclude test directory itself
91+
$components = array_filter(scandir($componentsDir), function ($item) use ($componentsDir, $componentExceptions) {
92+
return is_dir($componentsDir . $item) && !in_array($item, ['.', '..', ...$componentExceptions], true);
10293
});
10394

10495
foreach ($components as $component) {

0 commit comments

Comments
 (0)