| 1 | <?php |
||
| 2 | |||
| 3 | namespace MaksimM\ConditionalDebugBar\Tests; |
||
| 4 | |||
| 5 | use Barryvdh\Debugbar\ServiceProvider; |
||
| 6 | use MaksimM\ConditionalDebugBar\ConditionalDebugBarServiceProvider; |
||
| 7 | use MaksimM\ConditionalDebugBar\DebugModeBootValidators\TestingDebugBarBootValidator; |
||
| 8 | use MaksimM\ConditionalDebugBar\Http\Middleware\OptionalDebugBar; |
||
| 9 | use Orchestra\Testbench\BrowserKit\TestCase; |
||
| 10 | |||
| 11 | class DebugBarExceptedOptionTest extends TestCase |
||
| 12 | { |
||
| 13 | private $blank_page = '<html xmlns="http://www.w3.org/1999/html"><head></head><body</body</html>'; |
||
| 14 | |||
| 15 | /** @test */ |
||
| 16 | public function validateExcludedPage() |
||
| 17 | { |
||
| 18 | $crawler = $this->call('GET', 'excluded/page'); |
||
| 19 | $this->assertEquals($this->blank_page, $crawler->getContent()); |
||
| 20 | $this->assertNotContains('PhpDebugBar.DebugBar', $crawler->getContent()); |
||
| 21 | } |
||
| 22 | |||
| 23 | /** @test */ |
||
| 24 | public function validateExcludedPageWithSlash() |
||
| 25 | { |
||
| 26 | $crawler = $this->call('GET', '/excluded/another-page'); |
||
| 27 | $this->assertEquals($this->blank_page, $crawler->getContent()); |
||
| 28 | $this->assertNotContains('PhpDebugBar.DebugBar', $crawler->getContent()); |
||
| 29 | } |
||
| 30 | |||
| 31 | /** @test */ |
||
| 32 | public function validateIncludedPage() |
||
| 33 | { |
||
| 34 | $crawler = $this->call('GET', 'included/page'); |
||
| 35 | $this->assertNotEquals($this->blank_page, $crawler->getContent()); |
||
| 36 | $this->assertContains('PhpDebugBar.DebugBar', $crawler->getContent()); |
||
| 37 | } |
||
| 38 | |||
| 39 | protected function getPackageProviders($app) |
||
|
0 ignored issues
–
show
|
|||
| 40 | { |
||
| 41 | return [ServiceProvider::class, ConditionalDebugBarServiceProvider::class]; |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Define environment setup. |
||
| 46 | * |
||
| 47 | * @param Illuminate\Foundation\Application $app |
||
|
0 ignored issues
–
show
|
|||
| 48 | * |
||
| 49 | * @return void |
||
| 50 | */ |
||
| 51 | protected function getEnvironmentSetUp($app) |
||
| 52 | { |
||
| 53 | $app['config']->set('conditional-debugbar.debugbar-boot-validator', TestingDebugBarBootValidator::class); |
||
| 54 | $app['config']->set('debugbar.except', ['excluded/*']); |
||
| 55 | $app['router']->get('excluded/page', ['uses' => function () { |
||
| 56 | return $this->blank_page; |
||
| 57 | }])->middleware(OptionalDebugBar::class); |
||
| 58 | $app['router']->get('/excluded/another-page', ['uses' => function () { |
||
| 59 | return $this->blank_page; |
||
| 60 | }])->middleware(OptionalDebugBar::class); |
||
| 61 | $app['router']->get('included/page', ['uses' => function () { |
||
| 62 | return $this->blank_page; |
||
| 63 | }])->middleware(OptionalDebugBar::class); |
||
| 64 | } |
||
| 65 | } |
||
| 66 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.