Skip to content

Commit 26a32ab

Browse files
committed
wip
1 parent 60f4805 commit 26a32ab

File tree

3 files changed

+26
-37
lines changed

3 files changed

+26
-37
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"illuminate/console": "^7.13|^8.0",
2727
"illuminate/http": "^7.13|^8.0",
2828
"illuminate/support": "^7.13|^8.0",
29-
"nesbot/carbon": "^2.35"
29+
"nesbot/carbon": "^2.35",
30+
"spatie/laravel-package-tools": "^1.1"
3031
},
3132
"require-dev": {
3233
"laravel/framework": "^7.13|^8.0",

phpunit.xml.dist

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit bootstrap="vendor/autoload.php"
3-
backupGlobals="false"
4-
backupStaticAttributes="false"
5-
colors="true"
6-
verbose="true"
7-
convertErrorsToExceptions="true"
8-
convertNoticesToExceptions="true"
9-
convertWarningsToExceptions="true"
10-
processIsolation="false"
11-
stopOnFailure="false">
12-
<testsuites>
13-
<testsuite name="League Test Suite">
14-
<directory>tests</directory>
15-
</testsuite>
16-
</testsuites>
17-
<filter>
18-
<whitelist>
19-
<directory suffix=".php">src/</directory>
20-
</whitelist>
21-
</filter>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" 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="League Test Suite">
10+
<directory>tests</directory>
11+
</testsuite>
12+
</testsuites>
2213
</phpunit>

src/ResponseCacheServiceProvider.php

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,27 @@
55
use Illuminate\Cache\Repository;
66
use Illuminate\Container\Container;
77
use Illuminate\Support\ServiceProvider;
8+
use Spatie\LaravelPackageTools\Package;
9+
use Spatie\LaravelPackageTools\PackageServiceProvider;
810
use Spatie\ResponseCache\CacheProfiles\CacheProfile;
911
use Spatie\ResponseCache\Commands\ClearCommand;
1012
use Spatie\ResponseCache\Hasher\RequestHasher;
1113
use Spatie\ResponseCache\Serializers\Serializer;
1214

13-
class ResponseCacheServiceProvider extends ServiceProvider
15+
class ResponseCacheServiceProvider extends PackageServiceProvider
1416
{
15-
public function boot()
17+
public function configurePackage(Package $package): void
1618
{
17-
$this->publishes([
18-
__DIR__.'/../config/responsecache.php' => config_path('responsecache.php'),
19-
], 'config');
19+
$package
20+
->name('laravel-responsecache')
21+
->hasConfigFile()
22+
->hasCommands([
23+
ClearCommand::class,
24+
]);
25+
}
2026

27+
public function packageBooted()
28+
{
2129
$this->app->bind(CacheProfile::class, function (Container $app) {
2230
return $app->make(config('responsecache.cache_profile'));
2331
});
@@ -42,16 +50,5 @@ public function boot()
4250
});
4351

4452
$this->app->singleton('responsecache', ResponseCache::class);
45-
46-
if ($this->app->runningInConsole()) {
47-
$this->commands([
48-
ClearCommand::class,
49-
]);
50-
}
51-
}
52-
53-
public function register()
54-
{
55-
$this->mergeConfigFrom(__DIR__.'/../config/responsecache.php', 'responsecache');
5653
}
5754
}

0 commit comments

Comments
 (0)