| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
class CodexTokenDefaultsTest extends MediaWikiIntegrationTestCase { |
| 8 |
|
| 9 |
public function testTokenDefaults() { |
| 10 |
$resourcesPath = __DIR__ . '/../../../resources'; |
| 11 |
$codexTokensLess = "$resourcesPath/lib/codex-design-tokens/theme-wikimedia-ui.less"; |
| 12 |
$defaultsLess = "$resourcesPath/src/mediawiki.less/mediawiki.skin.defaults.less"; |
| 13 |
|
| 14 |
$codexVars = static::getVariableNames( $codexTokensLess ); |
| 15 |
$defaultVars = static::getVariableNames( $defaultsLess ); |
| 16 |
$missingVars = array_values( array_diff( $codexVars, $defaultVars ) ); |
| 17 |
$this->assertEquals( [], $missingVars ); |
| 18 |
} |
| 19 |
|
| 20 |
protected static function getVariableNames( $lessFilePath ) { |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
$fileContents = file_get_contents( $lessFilePath ); |
| 30 |
$matches = null; |
| 31 |
preg_match_all( '/^@([^:]+):/m', $fileContents, $matches, PREG_PATTERN_ORDER ); |
| 32 |
return $matches[1]; |
| 33 |
} |
| 34 |
} |