From 9f2841049eeae73550e7858534634e446880b7fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Tue, 25 Jun 2024 19:41:28 +0200 Subject: [PATCH 1/3] test: Do not skip TemplateLinterTest on Windows See https://github.com/symfony/maker-bundle/pull/1429/files#r1653262959. --- tests/Util/TemplateLinterTest.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/Util/TemplateLinterTest.php b/tests/Util/TemplateLinterTest.php index a441105a2..975972d1b 100644 --- a/tests/Util/TemplateLinterTest.php +++ b/tests/Util/TemplateLinterTest.php @@ -40,9 +40,7 @@ public function testExceptionThrownIfConfigPathDoesntExist(): void public function testPhpCsFixerVersion(): void { - if (str_contains(strtolower(\PHP_OS), 'win')) { - $this->markTestSkipped('Test only runs on linux.'); - } + $this->markTestSkippedOnWindows(); $fixerPath = sprintf('%s/src/Resources/bin/php-cs-fixer-v%s.phar', \dirname(__DIR__, 2), TemplateLinter::BUNDLED_PHP_CS_FIXER_VERSION); @@ -52,4 +50,13 @@ public function testPhpCsFixerVersion(): void self::assertStringContainsString(TemplateLinter::BUNDLED_PHP_CS_FIXER_VERSION, $process->getOutput()); } + + private function markTestSkippedOnWindows(): void + { + $isOnWindows = defined('PHP_WINDOWS_VERSION_MAJOR'); + + if ($isOnWindows) { + $this->markTestSkipped('Test only runs on linux.'); + } + } } From f79640efcc6cf8ed93609ef03ac47a2a21e48264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Tue, 25 Jun 2024 19:42:39 +0200 Subject: [PATCH 2/3] port change --- src/Util/TemplateLinter.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Util/TemplateLinter.php b/src/Util/TemplateLinter.php index 341ff956a..c7f8f06d9 100644 --- a/src/Util/TemplateLinter.php +++ b/src/Util/TemplateLinter.php @@ -59,7 +59,8 @@ public function lintPhpTemplate(string|array $templateFilePath): void $templateFilePath = [$templateFilePath]; } - $ignoreEnv = str_starts_with(strtolower(\PHP_OS), 'win') ? 'set PHP_CS_FIXER_IGNORE_ENV=1& ' : 'PHP_CS_FIXER_IGNORE_ENV=1 '; + $isWindows = defined('PHP_WINDOWS_VERSION_MAJOR'); + $ignoreEnv = $isWindows ? 'set PHP_CS_FIXER_IGNORE_ENV=1& ' : 'PHP_CS_FIXER_IGNORE_ENV=1 '; $cmdPrefix = $this->needsPhpCmdPrefix ? 'php ' : ''; From c40136ea939de9c321d8871be4adbab172dd9134 Mon Sep 17 00:00:00 2001 From: Jesse Rushlow Date: Wed, 31 Jul 2024 17:23:38 -0400 Subject: [PATCH 3/3] php-cs-fixer it up --- src/Util/TemplateLinter.php | 2 +- tests/Util/TemplateLinterTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Util/TemplateLinter.php b/src/Util/TemplateLinter.php index c7f8f06d9..4f1ee7ba9 100644 --- a/src/Util/TemplateLinter.php +++ b/src/Util/TemplateLinter.php @@ -59,7 +59,7 @@ public function lintPhpTemplate(string|array $templateFilePath): void $templateFilePath = [$templateFilePath]; } - $isWindows = defined('PHP_WINDOWS_VERSION_MAJOR'); + $isWindows = \defined('PHP_WINDOWS_VERSION_MAJOR'); $ignoreEnv = $isWindows ? 'set PHP_CS_FIXER_IGNORE_ENV=1& ' : 'PHP_CS_FIXER_IGNORE_ENV=1 '; $cmdPrefix = $this->needsPhpCmdPrefix ? 'php ' : ''; diff --git a/tests/Util/TemplateLinterTest.php b/tests/Util/TemplateLinterTest.php index 975972d1b..1caf7240e 100644 --- a/tests/Util/TemplateLinterTest.php +++ b/tests/Util/TemplateLinterTest.php @@ -53,7 +53,7 @@ public function testPhpCsFixerVersion(): void private function markTestSkippedOnWindows(): void { - $isOnWindows = defined('PHP_WINDOWS_VERSION_MAJOR'); + $isOnWindows = \defined('PHP_WINDOWS_VERSION_MAJOR'); if ($isOnWindows) { $this->markTestSkipped('Test only runs on linux.');