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 UnbootedDebugBarRouteTest extends TestCase |
11
|
|
|
{ |
12
|
|
|
|
13
|
|
|
private $blank_page = "<html xmlns=\"http://www.w3.org/1999/html\"><head></head><body</body</html>"; |
14
|
|
|
|
15
|
|
|
/** @test */ |
16
|
|
|
public function validateCleanPage() |
17
|
|
|
{ |
18
|
|
|
$crawler = $this->call('GET', 'sample-page'); |
19
|
|
|
$this->assertEquals($this->blank_page, $crawler->getContent()); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
/** @test */ |
23
|
|
|
public function validateAssetsAccessMiddleware() |
24
|
|
|
{ |
25
|
|
|
$this->validatePageWithMiddleware(); |
26
|
|
|
$crawler = $this->call('GET', route('debugbar.assets.js')); |
27
|
|
|
$this->assertEquals(404, $crawler->getStatusCode()); |
28
|
|
|
$crawler = $this->call('GET', route('debugbar.assets.css')); |
29
|
|
|
$this->assertEquals(404, $crawler->getStatusCode()); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** @test */ |
33
|
|
|
public function validatePageWithMiddleware() |
34
|
|
|
{ |
35
|
|
|
$crawler = $this->call('GET', 'page-with-middleware'); |
36
|
|
|
$this->assertEquals($this->blank_page, $crawler->getContent()); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
protected function getPackageProviders($app) |
|
|
|
|
40
|
|
|
{ |
41
|
|
|
return [ServiceProvider::class, ConditionalDebugBarServiceProvider::class]; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Define environment setup. |
46
|
|
|
* |
47
|
|
|
* @param Illuminate\Foundation\Application $app |
|
|
|
|
48
|
|
|
* |
49
|
|
|
* @return void |
50
|
|
|
*/ |
51
|
|
|
protected function getEnvironmentSetUp($app) |
52
|
|
|
{ |
53
|
|
|
$app['session']->flush(); |
54
|
|
|
$app['router']->get('sample-page', ['uses' => function () { |
55
|
|
|
return $this->blank_page; |
56
|
|
|
}]); |
57
|
|
|
$app['router']->get('page-with-middleware', ['uses' => function () { |
58
|
|
|
return $this->blank_page; |
59
|
|
|
}])->middleware(OptionalDebugBar::class); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
} |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.