From 64d7245f66791758eecff61361d1c7459d5e6532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sun, 29 Aug 2021 19:37:39 -0300 Subject: [PATCH] Fix unit tests on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- composer.json | 2 +- phpunit.xml.dist | 1 + test/classes/Command/TwigLintCommandTest.php | 28 ++++++++++---------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/composer.json b/composer.json index 496913e15195..c70f3c009014 100644 --- a/composer.json +++ b/composer.json @@ -112,7 +112,7 @@ "phpcbf": "phpcbf", "phpcs": "phpcs", "phpstan": "phpstan analyse", - "psalm": "psalm", + "psalm": "psalm --no-diff", "phpunit": "phpunit --color=always", "test": [ "@phpcs", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 7ab79d289e58..65d23eb76200 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -7,6 +7,7 @@ forceCoversAnnotation="true" verbose="true" executionOrder="random" + defaultTestSuite="unit" > diff --git a/test/classes/Command/TwigLintCommandTest.php b/test/classes/Command/TwigLintCommandTest.php index c86abd18dd9b..48fb584bdfaf 100644 --- a/test/classes/Command/TwigLintCommandTest.php +++ b/test/classes/Command/TwigLintCommandTest.php @@ -13,6 +13,8 @@ use function class_exists; use function sort; +use const DIRECTORY_SEPARATOR; +use const ROOT_PATH; use const SORT_NATURAL; use const SORT_REGULAR; @@ -50,26 +52,24 @@ public function testGetTemplateContents(): void public function testFindFiles(): void { - $filesFound = $this->callFunction($this->command, TwigLintCommand::class, 'findFiles', [ - ROOT_PATH . 'test/classes/_data/file_listing', - ]); + $path = ROOT_PATH . 'test/classes/_data/file_listing'; + $filesFound = $this->callFunction($this->command, TwigLintCommand::class, 'findFiles', [$path]); // Sort results to avoid file system test specific failures sort($filesFound, SORT_NATURAL); $this->assertEquals([ - ROOT_PATH . 'test/classes/_data/file_listing/one.txt', - ROOT_PATH . 'test/classes/_data/file_listing/subfolder/one.ini', - ROOT_PATH . 'test/classes/_data/file_listing/subfolder/zero.txt', - ROOT_PATH . 'test/classes/_data/file_listing/two.md', + $path . DIRECTORY_SEPARATOR . 'one.txt', + $path . DIRECTORY_SEPARATOR . 'subfolder' . DIRECTORY_SEPARATOR . 'one.ini', + $path . DIRECTORY_SEPARATOR . 'subfolder' . DIRECTORY_SEPARATOR . 'zero.txt', + $path . DIRECTORY_SEPARATOR . 'two.md', ], $filesFound); } public function testGetFilesInfo(): void { - $filesInfos = $this->callFunction($this->command, TwigLintCommand::class, 'getFilesInfo', [ - ROOT_PATH . 'test/classes/_data/file_listing', - ]); + $path = ROOT_PATH . 'test/classes/_data/file_listing'; + $filesInfos = $this->callFunction($this->command, TwigLintCommand::class, 'getFilesInfo', [$path]); // Sort results to avoid file system test specific failures sort($filesInfos, SORT_REGULAR); @@ -77,22 +77,22 @@ public function testGetFilesInfo(): void $this->assertEquals([ [ 'template' => '', - 'file' => ROOT_PATH . 'test/classes/_data/file_listing/one.txt', + 'file' => $path . DIRECTORY_SEPARATOR . 'one.txt', 'valid' => true, ], [ 'template' => '', - 'file' => ROOT_PATH . 'test/classes/_data/file_listing/two.md', + 'file' => $path . DIRECTORY_SEPARATOR . 'two.md', 'valid' => true, ], [ 'template' => '0000' . "\n", - 'file' => ROOT_PATH . 'test/classes/_data/file_listing/subfolder/zero.txt', + 'file' => $path . DIRECTORY_SEPARATOR . 'subfolder' . DIRECTORY_SEPARATOR . 'zero.txt', 'valid' => true, ], [ 'template' => 'key=value' . "\n", - 'file' => ROOT_PATH . 'test/classes/_data/file_listing/subfolder/one.ini', + 'file' => $path . DIRECTORY_SEPARATOR . 'subfolder' . DIRECTORY_SEPARATOR . 'one.ini', 'valid' => true, ], ], $filesInfos);