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 (#73)
by Jérémiah
07:13
created

ExecutorTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 7
dl 0
loc 78
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 16 1
A testInvalidExecutorReturnNotObject() 0 5 1
A testInvalidExecutorReturnInvalidObject() 0 5 1
A testDisabledDebugInfo() 0 4 1
A testEnabledDebugInfo() 0 8 1
A testGetSchemaNoSchemaFound() 0 4 1
A createExecutorExecuteMock() 0 10 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\Request;
13
14
use GraphQL\Schema;
15
use GraphQL\Type\Definition\ObjectType;
16
use GraphQL\Type\Definition\Type;
17
use Overblog\GraphQLBundle\Executor\Executor;
18
use Overblog\GraphQLBundle\Request\Executor as RequestExecutor;
19
20
class ExecutorTest extends \PHPUnit_Framework_TestCase
21
{
22
    /** @var RequestExecutor */
23
    private $executor;
24
25
    private $request = ['query' => 'query debug{ myField }', 'variables' => [], 'operationName' => null];
26
27
    public function setUp()
28
    {
29
        $this->executor = new RequestExecutor(new Executor());
30
        $queryType = new ObjectType([
31
            'name' => 'Query',
32
            'fields' => [
33
                'myField' => [
34
                    'type' => Type::boolean(),
35
                    'resolve' => function () {
36
                        return false;
37
                    },
38
                ],
39
            ],
40
        ]);
41
        $this->executor->addSchema('global', new Schema(['query' => $queryType]));
42
    }
43
44
    /**
45
     * @expectedException \RuntimeException
46
     * @expectedExceptionMessage Execution result should be an object instantiating "GraphQL\Executor\ExecutionResult" or "GraphQL\Executor\Promise\Promise".
47
     */
48
    public function testInvalidExecutorReturnNotObject()
49
    {
50
        $this->executor->setExecutor($this->createExecutorExecuteMock(false));
51
        $this->executor->execute($this->request);
52
    }
53
54
    /**
55
     * @expectedException \RuntimeException
56
     * @expectedExceptionMessage Execution result should be an object instantiating "GraphQL\Executor\ExecutionResult" or "GraphQL\Executor\Promise\Promise".
57
     */
58
    public function testInvalidExecutorReturnInvalidObject()
59
    {
60
        $this->executor->setExecutor($this->createExecutorExecuteMock(new \stdClass()));
61
        $this->executor->execute($this->request);
62
    }
63
64
    public function testDisabledDebugInfo()
65
    {
66
        $this->assertArrayNotHasKey('debug', $this->executor->disabledDebugInfo()->execute($this->request)->extensions);
67
    }
68
69
    public function testEnabledDebugInfo()
70
    {
71
        $result = $this->executor->enabledDebugInfo()->execute($this->request);
72
73
        $this->assertArrayHasKey('debug', $result->extensions);
74
        $this->assertArrayHasKey('executionTime', $result->extensions['debug']);
75
        $this->assertArrayHasKey('memoryUsage', $result->extensions['debug']);
76
    }
77
78
    /**
79
     * @expectedException \RuntimeException
80
     * @expectedExceptionMessage At least one schema should be declare.
81
     */
82
    public function testGetSchemaNoSchemaFound()
83
    {
84
        (new RequestExecutor(new Executor()))->getSchema('fake');
85
    }
86
87
    private function createExecutorExecuteMock($returnValue)
88
    {
89
        $mock = $this->getMockBuilder('Overblog\GraphQLBundle\Executor\Executor')
90
            ->setMethods(['execute'])
91
            ->getMock();
92
93
        $mock->method('execute')->will($this->returnValue($returnValue));
94
95
        return $mock;
96
    }
97
}
98