1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Orchestra\Testbench\BrowserKit\Tests; |
4
|
|
|
|
5
|
|
|
use Barryvdh\Debugbar\ServiceProvider; |
6
|
|
|
use MaksimM\ConditionalDebugBar\ConditionalDebugBarServiceProvider; |
7
|
|
|
use MaksimM\ConditionalDebugBar\Http\Middleware\OptionalDebugBar; |
8
|
|
|
use Orchestra\Testbench\BrowserKit\TestCase; |
9
|
|
|
|
10
|
|
|
class IntentionallyDisabledDebugBarRouteTest extends TestCase |
11
|
|
|
{ |
12
|
|
|
private $blank_page = '<html xmlns="http://www.w3.org/1999/html"><head></head><body</body</html>'; |
13
|
|
|
|
14
|
|
|
/** @test */ |
15
|
|
|
public function validateAssetsAccessMiddleware() |
16
|
|
|
{ |
17
|
|
|
$this->validatePageWithMiddleware(); |
18
|
|
|
$crawler = $this->call('GET', route('debugbar.assets.js')); |
19
|
|
|
$this->assertEquals(404, $crawler->getStatusCode()); |
20
|
|
|
$crawler = $this->call('GET', route('debugbar.assets.css')); |
21
|
|
|
$this->assertEquals(404, $crawler->getStatusCode()); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** @test */ |
25
|
|
|
public function validatePageWithMiddleware() |
26
|
|
|
{ |
27
|
|
|
$crawler = $this->call('GET', 'page-with-middleware'); |
28
|
|
|
$this->assertEquals($this->blank_page, $crawler->getContent()); |
29
|
|
|
$this->assertNotContains('PhpDebugBar.DebugBar', $crawler->getContent()); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
protected function getPackageProviders($app) |
|
|
|
|
33
|
|
|
{ |
34
|
|
|
return [ServiceProvider::class, ConditionalDebugBarServiceProvider::class]; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Define environment setup. |
39
|
|
|
* |
40
|
|
|
* @param Illuminate\Foundation\Application $app |
|
|
|
|
41
|
|
|
* |
42
|
|
|
* @return void |
43
|
|
|
*/ |
44
|
|
|
protected function getEnvironmentSetUp($app) |
45
|
|
|
{ |
46
|
|
|
$app['config']->set('debugbar.enabled', true); |
47
|
|
|
$app['config']->set('app.debug', true); |
48
|
|
|
resolve(\Barryvdh\Debugbar\LaravelDebugbar::class)->enable(); |
49
|
|
|
$app['router']->get('page-with-middleware', ['uses' => function () { |
50
|
|
|
return $this->blank_page; |
51
|
|
|
}])->middleware(OptionalDebugBar::class); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.