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

WithoutDebugBarRouteTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 13
dl 0
loc 39
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getEnvironmentSetUp() 0 9 1
A getPackageProviders() 0 3 1
A validatePageWithMiddleware() 0 4 1
A validateCleanPage() 0 4 1
1
<?php
2
3
namespace MaksimM\ConditionalDebugBar\Tests;
4
5
use MaksimM\ConditionalDebugBar\ConditionalDebugBarServiceProvider;
6
use MaksimM\ConditionalDebugBar\Http\Middleware\OptionalDebugBar;
7
use Orchestra\Testbench\BrowserKit\TestCase;
8
9
class WithoutDebugBarRouteTest extends TestCase
10
{
11
    private $blank_page = '<html xmlns="http://www.w3.org/1999/html"><head></head><body</body</html>';
12
13
    /** @test */
14
    public function validateCleanPage()
15
    {
16
        $crawler = $this->call('GET', 'sample-page');
17
        $this->assertEquals($this->blank_page, $crawler->getContent());
18
    }
19
20
    /** @test */
21
    public function validatePageWithMiddleware()
22
    {
23
        $crawler = $this->call('GET', 'page-with-middleware');
24
        $this->assertEquals($this->blank_page, $crawler->getContent());
25
    }
26
27
    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

27
    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...
28
    {
29
        return [ConditionalDebugBarServiceProvider::class];
30
    }
31
32
    /**
33
     * Define environment setup.
34
     *
35
     * @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...
36
     *
37
     * @return void
38
     */
39
    protected function getEnvironmentSetUp($app)
40
    {
41
        $app['session']->flush();
42
        $app['router']->get('sample-page', ['uses' => function () {
43
            return $this->blank_page;
44
        }]);
45
        $app['router']->get('page-with-middleware', ['uses' => function () {
46
            return $this->blank_page;
47
        }])->middleware(OptionalDebugBar::class);
48
    }
49
}
50