Skip to content

Commit 607e903

Browse files
committed
wip
1 parent 49c16a4 commit 607e903

File tree

6 files changed

+53
-22
lines changed

6 files changed

+53
-22
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ composer.lock
77

88
# PHP Unit
99
.phpunit.result.cache
10+
.phpunit.cache
1011

1112
# Assets
1213
/tmp

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"friendsofphp/php-cs-fixer": "^3.8",
2222
"nunomaduro/collision": "^4.1|^5.0|^6.0|^8.1",
2323
"orchestra/testbench": "^5.0|^6.0|^7.0|^8.0|^9.0|^10.0",
24-
"phpunit/phpunit": "^9.5|^10.0"
24+
"phpunit/phpunit": "^9.5|^10.0|^11.0"
2525
},
2626
"autoload": {
2727
"psr-4": {

phpunit.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" cacheResult="true" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3-
<coverage>
4-
<include>
5-
<directory suffix=".php">src/</directory>
6-
</include>
7-
</coverage>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" cacheResult="true" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
83
<testsuites>
94
<testsuite name="Swiftmade Test Suite">
105
<directory>tests</directory>
116
</testsuite>
127
</testsuites>
138
<php>
149
<env name="APP_ENV" value="testing"/>
15-
<env name="DB_CONNECTION" value="sqlite" />
16-
<env name="DB_DATABASE" value=":memory:" />
10+
<env name="DB_CONNECTION" value="sqlite"/>
11+
<env name="DB_DATABASE" value=":memory:"/>
1712
<env name="BCRYPT_ROUNDS" value="4"/>
1813
<env name="CACHE_DRIVER" value="array"/>
1914
<env name="SESSION_DRIVER" value="array"/>
2015
<env name="QUEUE_DRIVER" value="sync"/>
2116
<env name="MAIL_DRIVER" value="array"/>
2217
</php>
23-
</phpunit>
18+
<source>
19+
<include>
20+
<directory suffix=".php">src/</directory>
21+
</include>
22+
</source>
23+
</phpunit>

phpunit.xml.old

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" cacheResult="true" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage>
4+
<include>
5+
<directory suffix=".php">src/</directory>
6+
</include>
7+
</coverage>
8+
<testsuites>
9+
<testsuite name="Swiftmade Test Suite">
10+
<directory>tests</directory>
11+
</testsuite>
12+
</testsuites>
13+
<php>
14+
<env name="APP_ENV" value="testing"/>
15+
<env name="DB_CONNECTION" value="sqlite" />
16+
<env name="DB_DATABASE" value=":memory:" />
17+
<env name="BCRYPT_ROUNDS" value="4"/>
18+
<env name="CACHE_DRIVER" value="array"/>
19+
<env name="SESSION_DRIVER" value="array"/>
20+
<env name="QUEUE_DRIVER" value="sync"/>
21+
<env name="MAIL_DRIVER" value="array"/>
22+
</php>
23+
</phpunit>

src/ClearAssets.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public function handle()
4242
}
4343

4444
$unusedAssets
45-
->tap(fn ($assets) => $this->listAssets($assets))
46-
->tap(fn ($assets) => $this->comment(
45+
->tap(fn($assets) => $this->listAssets($assets))
46+
->tap(fn($assets) => $this->comment(
4747
sprintf(
4848
'Found %d unused %s, taking up %s of storage.',
4949
$assets->count(),
@@ -53,14 +53,14 @@ public function handle()
5353
)
5454
)
5555
))
56-
->tap(fn () => $this->presentChoices())
56+
->tap(fn() => $this->presentChoices())
5757
->when(
5858
$this->choice === self::CMD_DELETE_ALL,
59-
fn ($assets) => $assets->each(fn ($asset) => $this->removeAsset($asset))
59+
fn($assets) => $assets->each(fn($asset) => $this->removeAsset($asset))
6060
)
6161
->when(
6262
$this->choice === self::CMD_DELETE_BY_CHOICE,
63-
fn ($assets) => $assets->each(function ($asset) {
63+
fn($assets) => $assets->each(function ($asset) {
6464
if ($this->confirm('Delete "' . $asset->path() . '" ?')) {
6565
$this->removeAsset($asset);
6666
}
@@ -73,7 +73,7 @@ private function listAssets(AssetCollection $assets)
7373
$this->table(
7474
['Asset', 'Size'],
7575
$assets->map(
76-
fn ($asset) => [
76+
fn($asset) => [
7777
$asset->path(),
7878
$this->readableFilesize($asset->size()),
7979
]
@@ -87,15 +87,15 @@ private function filterUnused(AssetCollection $assets)
8787
// Skip assets that are in the ignored containers.
8888
$shouldIgnore = in_array(
8989
$asset->container()->handle(),
90-
config('statamic-clear-assets.ignore_containers')
90+
config('statamic-clear-assets.ignore_containers', [])
9191
);
9292

9393
if ($shouldIgnore) {
9494
return false;
9595
}
9696

9797
// Skip assets that match the ignore_filenames.
98-
foreach (config('statamic-clear-assets.ignore_filenames') as $pattern) {
98+
foreach (config('statamic-clear-assets.ignore_filenames', []) as $pattern) {
9999
if (Str::is($pattern, $asset->path())) {
100100
return false;
101101
}
@@ -110,8 +110,8 @@ private function filterUnused(AssetCollection $assets)
110110
});
111111

112112
collect(config('statamic-clear-assets.scan_folders', ['content', 'users']))
113-
->filter(fn ($folder) => file_exists(base_path($folder)))
114-
->map(fn ($folder) => File::allFiles(base_path($folder)))
113+
->filter(fn($folder) => file_exists(base_path($folder)))
114+
->map(fn($folder) => File::allFiles(base_path($folder)))
115115
->flatten()
116116
->unique()
117117
->each(function ($contentFile) use ($assets) {

tests/TestCase.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,15 @@ protected function resolveApplicationConfiguration($app)
9595
parent::resolveApplicationConfiguration($app);
9696

9797
$configs = [
98-
'assets', 'cp', 'forms', 'routes', 'static_caching',
99-
'sites', 'stache', 'system', 'users',
98+
'assets',
99+
'cp',
100+
'forms',
101+
'routes',
102+
'static_caching',
103+
'sites',
104+
'stache',
105+
'system',
106+
'users',
100107
];
101108

102109
foreach ($configs as $config) {

0 commit comments

Comments
 (0)