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