Skip to content
This repository has been archived by the owner on Feb 17, 2022. It is now read-only.

Commit

Permalink
Added more test to Transparent Middleware registration
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkGhostHunter committed Apr 9, 2019
1 parent 5b864ad commit 009cbf5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/CaptchavelServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected function bootMiddleware()
protected function shouldEnableMiddleware()
{
return $this->app->environment('production')
|| $this->app->environment('local') && $this->app->make('config')->get('captchavel.enable_local');
|| ($this->app->environment('local') && $this->app->make('config')->get('captchavel.enable_local'));
}

/**
Expand Down
18 changes: 17 additions & 1 deletion tests/ServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,26 @@ public function testDoesntRegisterInjectMiddlewareOnNonAuto()
);
}

public function testRegisterMiddlewareOnLocalTrue()
{
$this->app['env'] = 'local';
$this->app['config']->set('captchavel.enable_local', true);

/** @var CaptchavelServiceProvider $provider */
$provider = $this->app->make(CaptchavelServiceProvider::class, ['app' => $this->app]);

$provider->boot();

/** @var \Illuminate\Routing\Router $router */
$router = $this->app->make('router');

$this->assertEquals(CheckRecaptcha::class, $router->getMiddleware()['recaptcha']);
}

public function testPublishesConfigFile()
{
$this->artisan('vendor:publish', [
'--provider' => 'DarkGhostHunter\Captchavel\CaptchavelServiceProvider'
'--provider' => CaptchavelServiceProvider::class
]);

$this->assertFileExists(config_path('captchavel.php'));
Expand Down

0 comments on commit 009cbf5

Please sign in to comment.