Skip to content

Commit d4e0685

Browse files
theofidryjrushlow
andauthored
minor #1576 [ci] allow template linter tests on OSX (Darwin)
* test: Do not skip TemplateLinterTest on Windows See https://github.com/symfony/maker-bundle/pull/1429/files#r1653262959. * port change * php-cs-fixer it up --------- Co-authored-by: Jesse Rushlow <[email protected]>
1 parent bd3b4d2 commit d4e0685

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/Util/TemplateLinter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ public function lintPhpTemplate(string|array $templateFilePath): void
5959
$templateFilePath = [$templateFilePath];
6060
}
6161

62-
$ignoreEnv = str_starts_with(strtolower(\PHP_OS), 'win') ? 'set PHP_CS_FIXER_IGNORE_ENV=1& ' : 'PHP_CS_FIXER_IGNORE_ENV=1 ';
62+
$isWindows = \defined('PHP_WINDOWS_VERSION_MAJOR');
63+
$ignoreEnv = $isWindows ? 'set PHP_CS_FIXER_IGNORE_ENV=1& ' : 'PHP_CS_FIXER_IGNORE_ENV=1 ';
6364

6465
$cmdPrefix = $this->needsPhpCmdPrefix ? 'php ' : '';
6566

tests/Util/TemplateLinterTest.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ public function testExceptionThrownIfConfigPathDoesntExist(): void
4040

4141
public function testPhpCsFixerVersion(): void
4242
{
43-
if (str_contains(strtolower(\PHP_OS), 'win')) {
44-
$this->markTestSkipped('Test only runs on linux.');
45-
}
43+
$this->markTestSkippedOnWindows();
4644

4745
$fixerPath = \sprintf('%s/src/Resources/bin/php-cs-fixer-v%s.phar', \dirname(__DIR__, 2), TemplateLinter::BUNDLED_PHP_CS_FIXER_VERSION);
4846

@@ -52,4 +50,13 @@ public function testPhpCsFixerVersion(): void
5250

5351
self::assertStringContainsString(TemplateLinter::BUNDLED_PHP_CS_FIXER_VERSION, $process->getOutput());
5452
}
53+
54+
private function markTestSkippedOnWindows(): void
55+
{
56+
$isOnWindows = \defined('PHP_WINDOWS_VERSION_MAJOR');
57+
58+
if ($isOnWindows) {
59+
$this->markTestSkipped('Test only runs on linux.');
60+
}
61+
}
5562
}

0 commit comments

Comments
 (0)