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

Passed
Branch master (ddaabd)
by Jérémiah
05:38
created

GraphDumpSchemaCommandTest::testModernJsonFormat()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 14
loc 14
rs 9.4285
cc 1
eloc 9
nc 1
nop 0
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\Functional\Command;
13
14
use Overblog\GraphQLBundle\Command\GraphQLDumpSchemaCommand;
15
use Overblog\GraphQLBundle\Tests\Functional\TestCase;
16
use Symfony\Bundle\FrameworkBundle\Console\Application;
17
use Symfony\Component\Console\Command\Command;
18
use Symfony\Component\Console\Tester\CommandTester;
19
20
class GraphDumpSchemaCommandTest extends TestCase
21
{
22
    /**
23
     * @var Command
24
     */
25
    private $command;
26
27
    /**
28
     * @var CommandTester
29
     */
30
    private $commandTester;
31
32
    /**
33
     * @var string
34
     */
35
    private $cacheDir;
36
37
    public function setUp()
38
    {
39
        parent::setUp();
40
        $client = static::createClient(['test_case' => 'connection']);
41
        $kernel = $client->getKernel();
42
43
        $application = new Application($kernel);
44
        $application->add(new GraphQLDumpSchemaCommand());
45
        $this->command = $application->find('graphql:dump-schema');
46
        $this->commandTester = new CommandTester($this->command);
47
        $this->cacheDir = $kernel->getCacheDir();
48
    }
49
50
    /**
51
     * @param $format
52
     * @param bool $withFormatOption
53
     * @dataProvider formatDataProvider
54
     */
55
    public function testDump($format, $withFormatOption = true)
56
    {
57
        $file = $this->cacheDir.'/schema.'.$format;
58
59
        $input = [
60
            'command' => $this->command->getName(),
61
            '--file' => $file,
62
        ];
63
64
        if ($withFormatOption) {
65
            $input['--format'] = $format;
66
        }
67
        $this->assertCommandExecution(
68
            $input,
69
            __DIR__.'/fixtures/schema.'.$format,
70
            $file
71
        );
72
    }
73
74 View Code Duplication
    public function testClassicJsonFormat()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
75
    {
76
        $file = $this->cacheDir.'/schema.json';
77
        $this->assertCommandExecution(
78
            [
79
                'command' => $this->command->getName(),
80
                '--file' => $file,
81
                '--classic' => true,
82
                '--format' => 'json',
83
            ],
84
            __DIR__.'/fixtures/schema.json',
85
            $file
86
        );
87
    }
88
89 View Code Duplication
    public function testModernJsonFormat()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
90
    {
91
        $file = $this->cacheDir.'/schema.json';
92
        $this->assertCommandExecution(
93
            [
94
                'command' => $this->command->getName(),
95
                '--file' => $file,
96
                '--modern' => true,
97
                '--format' => 'json',
98
            ],
99
            __DIR__.'/fixtures/schema.modern.json',
100
            $file
101
        );
102
    }
103
104
    /**
105
     * @expectedException \InvalidArgumentException
106
     * @expectedExceptionMessage Unknown format "fake".
107
     */
108
    public function testInvalidFormat()
109
    {
110
        $this->commandTester->execute([
111
            'command' => $this->command->getName(),
112
            '--format' => 'fake',
113
        ]);
114
    }
115
116
    /**
117
     * @expectedException \InvalidArgumentException
118
     * @expectedExceptionMessage "modern" and "classic" options should not be used together.
119
     */
120
    public function testInvalidModernAndClassicUsedTogether()
121
    {
122
        $this->commandTester->execute([
123
            'command' => $this->command->getName(),
124
            '--format' => 'json',
125
            '--classic' => true,
126
            '--modern' => true,
127
        ]);
128
    }
129
130
    public function formatDataProvider()
131
    {
132
        return [
133
            ['json', false],
134
            ['json', true],
135
            ['graphqls'],
136
        ];
137
    }
138
139
    private function assertCommandExecution(array $input, $expectedFile, $actualFile, $expectedStatusCode = 0)
140
    {
141
        $this->commandTester->execute($input);
142
143
        $this->assertEquals($expectedStatusCode, $this->commandTester->getStatusCode());
144
        $this->assertEquals(trim(file_get_contents($expectedFile)), trim(file_get_contents($actualFile)));
145
    }
146
}
147