Passed
Push — master ( 70457d...6d3d31 )
by Maksim
04:43
created

validatePageWithMiddleware()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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 BootedDisabledDebugBarRouteTest 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 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(200, $crawler->getStatusCode());
28
        $crawler = $this->call('GET', route('debugbar.assets.css'));
29
        $this->assertEquals(200, $crawler->getStatusCode());
30
    }
31
32
    /** @test */
33
    public function validatePageWithMiddleware()
34
    {
35
        $crawler = $this->call('GET', 'page-with-middleware');
36
        $this->assertNotEquals($this->blank_page, $crawler->getContent());
37
        $this->assertContains('PhpDebugBar.DebugBar', $crawler->getContent());
38
    }
39
40
    protected function getPackageProviders($app)
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

40
    protected function getPackageProviders(/** @scrutinizer ignore-unused */ $app)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
41
    {
42
        return [ServiceProvider::class, ConditionalDebugBarServiceProvider::class];
43
    }
44
45
    /**
46
     * Define environment setup.
47
     *
48
     * @param Illuminate\Foundation\Application $app
0 ignored issues
show
Bug introduced by
The type MaksimM\ConditionalDebug...\Foundation\Application was not found. Did you mean Illuminate\Foundation\Application? If so, make sure to prefix the type with \.
Loading history...
49
     *
50
     * @return void
51
     */
52
    protected function getEnvironmentSetUp($app)
53
    {
54
        $app['config']->set('conditional-debugbar.debugbar-boot-validator', TestingDebugBarBootValidator::class);
55
        $app['config']->set('debugbar.enabled', false);
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