Skip to content

Commit

Permalink
Fix unit tests on Windows
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <[email protected]>
  • Loading branch information
MauricioFauth committed Aug 29, 2021
1 parent 9595362 commit 64d7245
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
"phpcbf": "phpcbf",
"phpcs": "phpcs",
"phpstan": "phpstan analyse",
"psalm": "psalm",
"psalm": "psalm --no-diff",
"phpunit": "phpunit --color=always",
"test": [
"@phpcs",
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
forceCoversAnnotation="true"
verbose="true"
executionOrder="random"
defaultTestSuite="unit"
>
<php>
<const name="PHPMYADMIN" value="1"/>
Expand Down
28 changes: 14 additions & 14 deletions test/classes/Command/TwigLintCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -50,49 +52,47 @@ 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);

$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);
Expand Down

0 comments on commit 64d7245

Please sign in to comment.