Issues (18)

tests/UnbootedDebugBarRouteTest.php (2 issues)

1
<?php
2
3
namespace MaksimM\ConditionalDebugBar\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
    private $blank_page = '<html xmlns="http://www.w3.org/1999/html"><head></head><body</body</html>';
13
14
    /** @test */
15
    public function validateCleanPage()
16
    {
17
        $crawler = $this->call('GET', 'sample-page');
18
        $this->assertEquals($this->blank_page, $crawler->getContent());
19
    }
20
21
    /** @test */
22
    public function validateAssetsAccessMiddleware()
23
    {
24
        $this->validatePageWithMiddleware();
25
        $crawler = $this->call('GET', route('debugbar.assets.js'));
26
        $this->assertEquals(404, $crawler->getStatusCode());
27
        $crawler = $this->call('GET', route('debugbar.assets.css'));
28
        $this->assertEquals(404, $crawler->getStatusCode());
29
    }
30
31
    /** @test */
32
    public function validatePageWithMiddleware()
33
    {
34
        $crawler = $this->call('GET', 'page-with-middleware');
35
        $this->assertEquals($this->blank_page, $crawler->getContent());
36
    }
37
38
    protected function getPackageProviders($app)
0 ignored issues
show
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

38
    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...
39
    {
40
        return [ServiceProvider::class, ConditionalDebugBarServiceProvider::class];
41
    }
42
43
    /**
44
     * Define environment setup.
45
     *
46
     * @param Illuminate\Foundation\Application $app
0 ignored issues
show
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...
47
     *
48
     * @return void
49
     */
50
    protected function getEnvironmentSetUp($app)
51
    {
52
        $app['session']->flush();
53
        $app['router']->get('sample-page', ['uses' => function () {
54
            return $this->blank_page;
55
        }]);
56
        $app['router']->get('page-with-middleware', ['uses' => function () {
57
            return $this->blank_page;
58
        }])->middleware(OptionalDebugBar::class);
59
    }
60
}
61