Passed
Pull Request — master (#9)
by Quang
02:23
created

GraphiQLTokenMiddlewareTest::testHandle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Digia\Lumen\GraphQL\Tests\Http;
4
5
use Digia\Lumen\GraphQL\Http\GraphiQLTokenMiddleware;
6
use Digia\Lumen\GraphQL\Tests\MiddlewareTestCase;
7
use Illuminate\Http\Request;
8
9
/**
10
 * Class GraphiQLTokenMiddlewareTest
11
 * @package ALehdet\ContentApi\Tests\Unit\GraphQL\Http\Middleware
12
 */
13
class GraphiQLTokenMiddlewareTest extends MiddlewareTestCase
14
{
15
16
    /**
17
     *
18
     */
19
    public function testHandle()
20
    {
21
        // Check that it passes when ENABLE_GRAPHIQL=true
22
        $this->assertMiddlewarePasses(new GraphiQLTokenMiddleware(true, null));
23
24
        // Check that it passes even if ENABLE_GRAPHIQL=false as long as a valid token is supplied
25
        $token   = 'foo';
26
        $request = new Request();
27
        $request->merge([
28
            'token' => $token,
29
        ]);
30
31
        $this->assertMiddlewarePasses(new GraphiQLTokenMiddleware(false, $token), $request);
32
    }
33
34
    /**
35
     * @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
36
     */
37
    public function testHandleFailed()
38
    {
39
        $this->assertMiddlewareThrows(new GraphiQLTokenMiddleware(false, null));
40
    }
41
42
}
43