Tweak service container

This commit is contained in:
Pig Fang 2019-08-22 10:49:05 +08:00
parent 28a4144ed1
commit 625cc08b81
2 changed files with 3 additions and 1 deletions

View File

@ -21,7 +21,8 @@ class AppServiceProvider extends ServiceProvider
public function register() public function register()
{ {
$this->app->singleton('cipher', 'App\Services\Cipher\\'.config('secure.cipher')); $this->app->singleton('cipher', 'App\Services\Cipher\\'.config('secure.cipher'));
$this->app->singleton('options', \App\Services\Option::class); $this->app->singleton(\App\Services\Option::class);
$this->app->alias(\App\Services\Option::class, 'options');
$this->app->singleton('parsedown', \Parsedown::class); $this->app->singleton('parsedown', \Parsedown::class);
$this->app->singleton('webpack', \App\Services\Webpack::class); $this->app->singleton('webpack', \App\Services\Webpack::class);
} }

View File

@ -36,6 +36,7 @@ class OptionTest extends TestCase
$mock->shouldReceive('getRequire')->with($path)->once()->andReturn(['k' => 'v']); $mock->shouldReceive('getRequire')->with($path)->once()->andReturn(['k' => 'v']);
}); });
app()->forgetInstance(Option::class);
$options = resolve(Option::class); $options = resolve(Option::class);
$this->assertEquals('v', $options->get('k')); $this->assertEquals('v', $options->get('k'));
} }