Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — master (#72)
by Jérémiah
07:56
created

ExecutorTest::addSchema()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 16
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 9
nc 1
nop 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A ExecutorTest::testInvalidExecutorReturnInvalidObject() 0 5 1
A ExecutorTest::testDisabledDebugInfo() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the OverblogGraphQLBundle package.
5
 *
6
 * (c) Overblog <http://github.com/overblog/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Overblog\GraphQLBundle\Tests\Resolver;
13
14
use GraphQL\Schema;
15
use GraphQL\Type\Definition\ObjectType;
16
use GraphQL\Type\Definition\Type;
17
use Overblog\GraphQLBundle\Request\Executor;
18
19
class ExecutorTest extends \PHPUnit_Framework_TestCase
20
{
21
    /** @var Executor */
22
    private $executor;
23
24
    private $request = ['query' => 'query debug{ myField }', 'variables' => [], 'operationName' => null];
25
26
    public function setUp()
27
    {
28
        $this->executor = new Executor();
29
        $queryType = new ObjectType([
30
            'name' => 'Query',
31
            'fields' => [
32
                'myField' => [
33
                    'type' => Type::boolean(),
34
                    'resolve' => function () {
35
                        return false;
36
                    },
37
                ],
38
            ],
39
        ]);
40
        $this->executor->addSchema('global', new Schema(['query' => $queryType]));
41
    }
42
43
    /**
44
     * @expectedException \RuntimeException
45
     * @expectedExceptionMessage Execution result should be an object instantiating "GraphQL\Executor\ExecutionResult".
46
     */
47
    public function testInvalidExecutorReturnNotObject()
48
    {
49
        $this->executor->setExecutor(function() { return false; });
50
        $this->executor->execute($this->request);
51
    }
52
53
    /**
54
     * @expectedException \RuntimeException
55
     * @expectedExceptionMessage Execution result should be an object instantiating "GraphQL\Executor\ExecutionResult".
56
     */
57
    public function testInvalidExecutorReturnInvalidObject()
58
    {
59
        $this->executor->setExecutor(function() { return new \stdClass(); });
60
        $this->executor->execute($this->request);
61
    }
62
63
    public function testDisabledDebugInfo()
64
    {
65
        $this->assertArrayNotHasKey('debug', $this->executor->disabledDebugInfo()->execute($this->request)->extensions);
66
    }
67
68
    public function testEnabledDebugInfo()
69
    {
70
        $result = $this->executor->enabledDebugInfo()->execute($this->request);
71
72
        $this->assertArrayHasKey('debug', $result->extensions);
73
        $this->assertArrayHasKey('executionTime', $result->extensions['debug']);
74
        $this->assertArrayHasKey('memoryUsage', $result->extensions['debug']);
75
    }
76
77
    /**
78
     * @expectedException \RuntimeException
79
     * @expectedExceptionMessage At least one schema should be declare.
80
     */
81
    public function testGetSchemaNoSchemaFound()
82
    {
83
        (new Executor())->getSchema('fake');
84
    }
85
}
86