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 (#264)
by Jérémiah
12:16
created

ExecutorTest::testDisabledDebugInfo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Overblog\GraphQLBundle\Tests\Request;
4
5
use GraphQL\Executor\Promise\Adapter\ReactPromiseAdapter;
6
use GraphQL\Type\Definition\ObjectType;
7
use GraphQL\Type\Definition\Type;
8
use GraphQL\Type\Schema;
9
use Overblog\GraphQLBundle\Executor\Executor;
10
use Overblog\GraphQLBundle\Request\Executor as RequestExecutor;
11
use PHPUnit\Framework\TestCase;
12
use Symfony\Component\EventDispatcher\EventDispatcher;
13
14
class ExecutorTest extends TestCase
15
{
16
    /** @var RequestExecutor */
17
    private $executor;
18
19
    /** @var EventDispatcher|\PHPUnit_Framework_MockObject_MockObject */
20
    private $dispatcher;
21
22
    private $request = ['query' => 'query debug{ myField }', 'variables' => [], 'operationName' => null];
23
24
    public function setUp()
25
    {
26
        $this->dispatcher = $this->getMockBuilder(EventDispatcher::class)->setMethods(['dispatch'])->getMock();
27
        $this->dispatcher->expects($this->any())->method('dispatch')->willReturnArgument(1);
28
29
        $this->executor = new RequestExecutor(new Executor(), $this->dispatcher);
0 ignored issues
show
Documentation introduced by
$this->dispatcher is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Symfony\Component...entDispatcherInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
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".
47
     */
48
    public function testInvalidExecutorReturnNotObject()
49
    {
50
        $this->executor->setExecutor($this->createExecutorExecuteMock(false));
0 ignored issues
show
Documentation introduced by
$this->createExecutorExecuteMock(false) is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Overblog\GraphQLB...utor\ExecutorInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
51
        $this->executor->execute(null, $this->request);
52
    }
53
54
    /**
55
     * @expectedException \RuntimeException
56
     * @expectedExceptionMessage Execution result should be an object instantiating "GraphQL\Executor\ExecutionResult".
57
     */
58
    public function testInvalidExecutorReturnInvalidObject()
59
    {
60
        $this->executor->setExecutor($this->createExecutorExecuteMock(new \stdClass()));
0 ignored issues
show
Documentation introduced by
$this->createExecutorExecuteMock(new \stdClass()) is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Overblog\GraphQLB...utor\ExecutorInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
61
        $this->executor->execute(null, $this->request);
62
    }
63
64
    /**
65
     * @expectedException \RuntimeException
66
     * @expectedExceptionMessage PromiseAdapter should be an object instantiating "Overblog\GraphQLBundle\Executor\Promise\PromiseAdapterInterface" or "GraphQL\Executor\Promise\PromiseAdapter" with a "wait" method.
67
     */
68
    public function testInvalidExecutorAdapterPromise()
69
    {
70
        $this->executor->setPromiseAdapter(new ReactPromiseAdapter());
71
        $this->executor->execute(null, $this->request);
72
    }
73
74
    /**
75
     * @expectedException \RuntimeException
76
     * @expectedExceptionMessage At least one schema should be declare.
77
     */
78
    public function testGetSchemaNoSchemaFound()
79
    {
80
        (new RequestExecutor(new Executor(), $this->dispatcher))->getSchema('fake');
81
    }
82
83
    private function createExecutorExecuteMock($returnValue)
84
    {
85
        $mock = $this->getMockBuilder(Executor::class)
86
            ->setMethods(['execute'])
87
            ->getMock();
88
89
        $mock->method('execute')->will($this->returnValue($returnValue));
90
91
        return $mock;
92
    }
93
}
94