Skip to content

Commit 0830b7e

Browse files
authored
Merge pull request #67 from tighten/adc/default-exclude-files
Move commonly excluded files to DusterConfig
2 parents 6a7a89b + 50a0a84 commit 0830b7e

File tree

4 files changed

+75
-10
lines changed

4 files changed

+75
-10
lines changed

app/Support/DusterConfig.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ class DusterConfig
1212
public function __construct(
1313
protected array $config = []
1414
) {
15+
$this->config['exclude'] = array_merge(
16+
$this->config['exclude'] ?? [],
17+
[
18+
'_ide_helper_actions.php',
19+
'_ide_helper_models.php',
20+
'_ide_helper.php',
21+
'.phpstorm.meta.php',
22+
'bootstrap/cache',
23+
'build',
24+
'node_modules',
25+
'storage',
26+
]
27+
);
1528
}
1629

1730
public function get(string $key, mixed $default = null): mixed

app/Support/PhpCsFixer.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,8 @@ public static function getFinder(): Finder
2222
{
2323
return Finder::create()
2424
->notName([
25-
'_ide_helper_actions.php',
26-
'_ide_helper_models.php',
27-
'_ide_helper.php',
28-
'.phpstorm.meta.php',
2925
'*.blade.php',
3026
])
31-
->exclude([
32-
'bootstrap/cache',
33-
'build',
34-
'node_modules',
35-
'storage',
36-
])
3727
->ignoreDotFiles(true)
3828
->ignoreVCS(true);
3929
}

phpunit.xml.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
<testsuite name="Feature">
1313
<directory suffix="Test.php">./tests/Feature</directory>
1414
</testsuite>
15+
<testsuite name="Unit">
16+
<directory suffix="Test.php">./tests/Unit</directory>
17+
</testsuite>
1518
<testsuite name="Fixer">
1619
<directory suffix="Test.php">./tests/Fixer</directory>
1720
</testsuite>

tests/Unit/DusterConfigTest.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
use App\Support\DusterConfig;
4+
5+
it('provides config values', function () {
6+
$dusterConfig = new DusterConfig([
7+
'paths' => ['path1', 'path2'],
8+
'lint' => true,
9+
'fix' => false,
10+
'using' => ['tlint', 'phpcs', 'php-cs-fixer', 'pint'],
11+
]);
12+
13+
expect($dusterConfig->get('paths'))->toBe(['path1', 'path2']);
14+
expect($dusterConfig->get('lint'))->toBeTrue();
15+
expect($dusterConfig->get('fix'))->toBeFalse();
16+
expect($dusterConfig->get('using'))->toBe(['tlint', 'phpcs', 'php-cs-fixer', 'pint']);
17+
});
18+
19+
it('provides default exclude config values', function () {
20+
$dusterConfig = new DusterConfig([
21+
'paths' => ['path1', 'path2'],
22+
'lint' => true,
23+
'fix' => false,
24+
'using' => ['tlint', 'phpcs', 'php-cs-fixer', 'pint'],
25+
]);
26+
27+
expect($dusterConfig->get('exclude'))->toBe([
28+
'_ide_helper_actions.php',
29+
'_ide_helper_models.php',
30+
'_ide_helper.php',
31+
'.phpstorm.meta.php',
32+
'bootstrap/cache',
33+
'build',
34+
'node_modules',
35+
'storage',
36+
]);
37+
});
38+
39+
it('merges provided exclude with default exclude config values', function () {
40+
$dusterConfig = new DusterConfig([
41+
'paths' => ['path1', 'path2'],
42+
'lint' => true,
43+
'fix' => false,
44+
'using' => ['tlint', 'phpcs', 'php-cs-fixer', 'pint'],
45+
'exclude' => ['vendor'],
46+
]);
47+
48+
expect($dusterConfig->get('exclude'))->toBe([
49+
'vendor',
50+
'_ide_helper_actions.php',
51+
'_ide_helper_models.php',
52+
'_ide_helper.php',
53+
'.phpstorm.meta.php',
54+
'bootstrap/cache',
55+
'build',
56+
'node_modules',
57+
'storage',
58+
]);
59+
});

0 commit comments

Comments
 (0)