Skip to content

Commit 1840011

Browse files
author
Jeremiah VALERIE
committed
Merge branch '0.11' into 0.12
2 parents db3743d + 869794a commit 1840011

File tree

12 files changed

+85
-40
lines changed

12 files changed

+85
-40
lines changed

.travis.yml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,22 @@ jobs:
3838
env: SYMFONY_VERSION=4.0.* PHPUNIT_VERSION=^7.2
3939
- php: 7.2
4040
env: SYMFONY_VERSION=4.1.* PHPUNIT_VERSION=^7.2
41-
- php: 7.3
42-
env: SYMFONY_VERSION=4.2.*
4341
- php: 7.3
4442
env: SYMFONY_VERSION=4.3.* SYMFONY_DEPRECATIONS_HELPER=max[total]=0
4543
- php: 7.3
4644
env: SYMFONY_VERSION=4.3.* USE_EXPERIMENTAL_EXECUTOR=1 SYMFONY_DEPRECATIONS_HELPER=max[total]=0
4745
- php: 7.3
48-
env: SYMFONY_VERSION=4.4.* STABILITY=dev SYMFONY_DEPRECATIONS_HELPER=max[total]=0
46+
env: SYMFONY_VERSION=4.4.* SYMFONY_DEPRECATIONS_HELPER=max[total]=0
4947
- php: 7.3
50-
env: SYMFONY_VERSION=5.0.* STABILITY=dev SYMFONY_DEPRECATIONS_HELPER=max[total]=0
48+
env: SYMFONY_VERSION=5.0.* SYMFONY_DEPRECATIONS_HELPER=max[total]=0
5149
- php: 7.4snapshot
5250
env: SYMFONY_VERSION=4.3.*
5351
- php: nightly
5452
env: COMPOSER_UPDATE_FLAGS=--ignore-platform-reqs
5553

5654
- stage: Code Quality
5755
php: 7.2
58-
env: COVERAGE
56+
env: COVERAGE SYMFONY_VERSION=4.4.*
5957
before_script:
6058
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,}
6159
- if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi
@@ -66,7 +64,7 @@ jobs:
6664

6765
- stage: Code Quality
6866
php: 7.2
69-
env: STATIC_ANALYSIS
67+
env: STATIC_ANALYSIS SYMFONY_VERSION=4.3.*
7068
install: travis_retry composer install --prefer-dist
7169
script: composer static-analysis
7270

@@ -82,8 +80,3 @@ jobs:
8280

8381
allow_failures:
8482
- php: nightly
85-
- php: 7.4snapshot
86-
- php: 7.3
87-
env: SYMFONY_VERSION=4.4.* STABILITY=dev SYMFONY_DEPRECATIONS_HELPER=max[total]=0
88-
- php: 7.3
89-
env: SYMFONY_VERSION=5.0.* STABILITY=dev SYMFONY_DEPRECATIONS_HELPER=max[total]=0

composer.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131
"php": ">=7.1",
3232
"ext-json": "*",
3333
"psr/log": "^1.0",
34-
"symfony/config": "^3.4 || ^4.0",
35-
"symfony/dependency-injection": "^3.4 || ^4.0",
36-
"symfony/event-dispatcher": "^3.4 || ^4.0",
37-
"symfony/expression-language": "^3.4 || ^4.0",
38-
"symfony/framework-bundle": "^3.4 || ^4.0",
39-
"symfony/options-resolver": "^3.4 || ^4.0",
40-
"symfony/property-access": "^3.4 || ^4.0",
34+
"symfony/config": "^3.4 || ^4.0 || ^5.0",
35+
"symfony/dependency-injection": "^3.4 || ^4.0 || ^5.0",
36+
"symfony/event-dispatcher": "^3.4 || ^4.0 || ^5.0",
37+
"symfony/expression-language": "^3.4 || ^4.0 || ^5.0",
38+
"symfony/framework-bundle": "^3.4 || ^4.0 || ^5.0",
39+
"symfony/options-resolver": "^3.4 || ^4.0 || ^5.0",
40+
"symfony/property-access": "^3.4 || ^4.0 || ^5.0",
4141
"webonyx/graphql-php": "^0.13.5"
4242
},
4343
"replace": {
@@ -52,15 +52,15 @@
5252
"doctrine/orm": "^2.5",
5353
"phpunit/phpunit": "<8.3",
5454
"react/promise": "^2.5",
55-
"symfony/asset": "^3.4 || ^4.0",
56-
"symfony/browser-kit": "^3.4 || ^4.0",
57-
"symfony/console": "^3.4 || ^4.0",
58-
"symfony/css-selector": "^3.4 || ^4.0",
59-
"symfony/phpunit-bridge": "^3.4 || ^4.0",
60-
"symfony/process": "^3.4 || ^4.0",
61-
"symfony/security-bundle": "^3.4 || ^4.0",
62-
"symfony/validator": "^3.4 || ^4.0",
63-
"symfony/yaml": "^3.4 || ^4.0"
55+
"symfony/asset": "^3.4 || ^4.0 || ^5.0",
56+
"symfony/browser-kit": "^3.4 || ^4.0 || ^5.0",
57+
"symfony/console": "^3.4 || ^4.0 || ^5.0",
58+
"symfony/css-selector": "^3.4 || ^4.0 || ^5.0",
59+
"symfony/phpunit-bridge": "^3.4 || ^4.0 || ^5.0",
60+
"symfony/process": "^3.4 || ^4.0 || ^5.0",
61+
"symfony/security-bundle": "^3.4 || ^4.0 || ^5.0",
62+
"symfony/validator": "^3.4 || ^4.0 || ^5.0",
63+
"symfony/yaml": "^3.4 || ^4.0 || ^5.0"
6464
},
6565
"extra": {
6666
"branch-alias": {

src/Command/CompileCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ protected function configure(): void
2929
;
3030
}
3131

32-
protected function execute(InputInterface $input, OutputInterface $output): void
32+
protected function execute(InputInterface $input, OutputInterface $output): int
3333
{
3434
$output->writeln('<info>Types compilation starts</info>');
3535
$classes = $this->typeGenerator->compile(TypeGenerator::MODE_WRITE | TypeGenerator::MODE_OVERRIDE);
@@ -43,5 +43,7 @@ protected function execute(InputInterface $input, OutputInterface $output): void
4343
}
4444
$io->table(['class', 'path'], $rows);
4545
}
46+
47+
return 0;
4648
}
4749
}

src/Command/DebugCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected function configure(): void
5858
->setDescription('Display current GraphQL services (types, resolvers and mutations)');
5959
}
6060

61-
protected function execute(InputInterface $input, OutputInterface $output): void
61+
protected function execute(InputInterface $input, OutputInterface $output): int
6262
{
6363
$categoriesOption = $input->getOption('category');
6464
$categoriesOption = \is_array($categoriesOption) ? $categoriesOption : [$categoriesOption];
@@ -79,6 +79,8 @@ protected function execute(InputInterface $input, OutputInterface $output): void
7979
$resolver = $this->{$category.'Resolver'};
8080
$this->renderTable($resolver, $tableHeaders, $io);
8181
}
82+
83+
return 0;
8284
}
8385

8486
/**

src/Command/GraphQLDumpSchemaCommand.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,13 @@ protected function configure(): void
7979
;
8080
}
8181

82-
protected function execute(InputInterface $input, OutputInterface $output): void
82+
protected function execute(InputInterface $input, OutputInterface $output): int
8383
{
8484
$io = new SymfonyStyle($input, $output);
8585
$file = $this->createFile($input);
8686
$io->success(\sprintf('GraphQL schema "%s" was successfully dumped.', \realpath($file)));
87+
88+
return 0;
8789
}
8890

8991
private function createFile(InputInterface $input)
@@ -92,7 +94,7 @@ private function createFile(InputInterface $input)
9294
$schemaName = $input->getOption('schema');
9395
$includeDescription = $input->getOption('with-descriptions');
9496

95-
$file = $input->getOption('file') ?: $this->baseExportPath.\sprintf('/../var/schema%s.%s', $schemaName ? '.'.$schemaName : '', $format);
97+
$file = $input->getOption('file') ?: $this->baseExportPath.\sprintf('/var/schema%s.%s', $schemaName ? '.'.$schemaName : '', $format);
9698

9799
switch ($format) {
98100
case 'json':

src/Command/ValidateCommand.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected function configure(): void
4747
;
4848
}
4949

50-
protected function execute(InputInterface $input, OutputInterface $output): void
50+
protected function execute(InputInterface $input, OutputInterface $output): int
5151
{
5252
Warning::suppress(true);
5353

@@ -59,8 +59,10 @@ protected function execute(InputInterface $input, OutputInterface $output): void
5959
} catch (InvariantViolation $e) {
6060
$output->writeln('<comment>'.$e->getMessage().'</comment>');
6161

62-
return;
62+
return 1;
6363
}
6464
$output->writeln('<info>No error</info>');
65+
66+
return 0;
6567
}
6668
}

tests/Config/Parser/TestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
namespace Overblog\GraphQLBundle\Tests\Config\Parser;
66

77
use PHPUnit\Framework\MockObject\MockObject;
8-
use Symfony\Bundle\FrameworkBundle\Tests\TestCase as BaseTestCase;
8+
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
99
use Symfony\Component\DependencyInjection\ContainerBuilder;
1010

11-
abstract class TestCase extends BaseTestCase
11+
abstract class TestCase extends WebTestCase
1212
{
1313
/** @var ContainerBuilder|MockObject */
1414
protected $containerBuilder;

tests/Functional/App/TestKernel.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ public function getLogDir()
4242
return $this->basePath().'logs';
4343
}
4444

45+
public function getProjectDir()
46+
{
47+
return __DIR__;
48+
}
49+
4550
public function getRootDir()
4651
{
4752
return __DIR__;
@@ -83,4 +88,15 @@ private function basePath()
8388
{
8489
return \sys_get_temp_dir().'/OverblogGraphQLBundle/'.Kernel::VERSION.'/'.($this->testCase ? $this->testCase.'/' : '');
8590
}
91+
92+
protected function build(ContainerBuilder $container): void
93+
{
94+
if (!$container->hasParameter('kernel.root_dir')) {
95+
$container->setParameter('kernel.root_dir', $this->getRootDir());
96+
}
97+
98+
if (!$container->hasParameter('kernel.project_dir')) {
99+
$container->setParameter('kernel.project_dir', $this->getProjectDir());
100+
}
101+
}
86102
}

tests/Functional/Command/ValidateCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function testValidSchemaThrowException(): void
5555
$this->command->setRequestExecutor($executor);
5656

5757
$this->commandTester->execute(['--schema' => 'foo']);
58-
$this->assertEquals(0, $this->commandTester->getStatusCode());
58+
$this->assertEquals(1, $this->commandTester->getStatusCode());
5959
$this->assertEquals('broken schema', \trim($this->commandTester->getDisplay()));
6060
}
6161
}

tests/Functional/Controller/GraphControllerTest.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class GraphControllerTest extends TestCase
6767
public function testEndpointAction($uri): void
6868
{
6969
$client = static::createClient(['test_case' => 'connectionWithCORS']);
70+
$this->disableCatchExceptions($client);
7071

7172
$client->request('GET', $uri, ['query' => $this->friendsQuery], [], ['CONTENT_TYPE' => 'application/graphql;charset=utf8', 'HTTP_Origin' => 'http://example.com']);
7273
$result = $client->getResponse()->getContent();
@@ -87,6 +88,7 @@ public function testEndpointWithEmptyQuery(): void
8788
$this->expectException(BadRequestHttpException::class);
8889
$this->expectExceptionMessage('Must provide query parameter');
8990
$client = static::createClient();
91+
$this->disableCatchExceptions($client);
9092
$client->request('GET', '/', []);
9193
$client->getResponse()->getContent();
9294
}
@@ -96,12 +98,14 @@ public function testEndpointWithEmptyPostJsonBodyQuery(): void
9698
$this->expectException(BadRequestHttpException::class);
9799
$this->expectExceptionMessage('The request content body must not be empty when using json content type request.');
98100
$client = static::createClient();
101+
$this->disableCatchExceptions($client);
99102
$client->request('POST', '/', [], [], ['CONTENT_TYPE' => 'application/json']);
100103
}
101104

102105
public function testEndpointWithJsonContentTypeAndGetQuery(): void
103106
{
104107
$client = static::createClient(['test_case' => 'connectionWithCORS']);
108+
$this->disableCatchExceptions($client);
105109
$client->request('GET', '/', ['query' => $this->friendsQuery], [], ['CONTENT_TYPE' => 'application/json']);
106110
$result = $client->getResponse()->getContent();
107111
$this->assertSame(['data' => $this->expectedData], \json_decode($result, true), $result);
@@ -112,13 +116,15 @@ public function testEndpointWithInvalidBodyQuery(): void
112116
$this->expectException(BadRequestHttpException::class);
113117
$this->expectExceptionMessage('POST body sent invalid JSON');
114118
$client = static::createClient();
119+
$this->disableCatchExceptions($client);
115120
$client->request('GET', '/', [], [], ['CONTENT_TYPE' => 'application/json'], '{');
116121
$client->getResponse()->getContent();
117122
}
118123

119124
public function testEndpointActionWithVariables(): void
120125
{
121126
$client = static::createClient(['test_case' => 'connection']);
127+
$this->disableCatchExceptions($client);
122128

123129
$query = <<<'EOF'
124130
query FriendsQuery($firstFriends: Int) {
@@ -146,6 +152,7 @@ public function testEndpointActionWithInvalidVariables(): void
146152
$this->expectException(BadRequestHttpException::class);
147153
$this->expectExceptionMessage('Variables are invalid JSON');
148154
$client = static::createClient(['test_case' => 'connection']);
155+
$this->disableCatchExceptions($client);
149156

150157
$query = <<<'EOF'
151158
query {
@@ -161,6 +168,7 @@ public function testMultipleEndpointActionWithUnknownSchemaName(): void
161168
$this->expectException(NotFoundHttpException::class);
162169
$this->expectExceptionMessage('Could not found "fake" schema.');
163170
$client = static::createClient(['test_case' => 'connection']);
171+
$this->disableCatchExceptions($client);
164172

165173
$query = <<<'EOF'
166174
query {
@@ -174,6 +182,7 @@ public function testMultipleEndpointActionWithUnknownSchemaName(): void
174182
public function testEndpointActionWithOperationName(): void
175183
{
176184
$client = static::createClient(['test_case' => 'connection']);
185+
$this->disableCatchExceptions($client);
177186

178187
$query = $this->friendsQuery."\n".$this->friendsTotalCountQuery;
179188

@@ -189,6 +198,7 @@ public function testEndpointActionWithOperationName(): void
189198
public function testBatchEndpointAction($uri): void
190199
{
191200
$client = static::createClient(['test_case' => 'connection']);
201+
$this->disableCatchExceptions($client);
192202

193203
$data = [
194204
[
@@ -224,6 +234,7 @@ public function testBatchEndpointWithEmptyQuery(): void
224234
$this->expectException(BadRequestHttpException::class);
225235
$this->expectExceptionMessage('Must provide at least one valid query.');
226236
$client = static::createClient();
237+
$this->disableCatchExceptions($client);
227238
$client->request('GET', '/batch', [], [], ['CONTENT_TYPE' => 'application/json'], '{}');
228239
$client->getResponse()->getContent();
229240
}
@@ -233,6 +244,7 @@ public function testBatchEndpointWrongContentType(): void
233244
$this->expectException(BadRequestHttpException::class);
234245
$this->expectExceptionMessage('Batching parser only accepts "application/json" or "multipart/form-data" content-type but got "".');
235246
$client = static::createClient();
247+
$this->disableCatchExceptions($client);
236248
$client->request('GET', '/batch');
237249
$client->getResponse()->getContent();
238250
}
@@ -242,6 +254,7 @@ public function testBatchEndpointWithInvalidJson(): void
242254
$this->expectException(BadRequestHttpException::class);
243255
$this->expectExceptionMessage('POST body sent invalid JSON');
244256
$client = static::createClient();
257+
$this->disableCatchExceptions($client);
245258
$client->request('GET', '/batch', [], [], ['CONTENT_TYPE' => 'application/json'], '{');
246259
$client->getResponse()->getContent();
247260
}
@@ -251,13 +264,15 @@ public function testBatchEndpointWithInvalidQuery(): void
251264
$this->expectException(BadRequestHttpException::class);
252265
$this->expectExceptionMessage('1 is not a valid query');
253266
$client = static::createClient();
267+
$this->disableCatchExceptions($client);
254268
$client->request('GET', '/batch', [], [], ['CONTENT_TYPE' => 'application/json'], '{"test" : {"query": 1}}');
255269
$client->getResponse()->getContent();
256270
}
257271

258272
public function testPreflightedRequestWhenDisabled(): void
259273
{
260274
$client = static::createClient(['test_case' => 'connection']);
275+
$this->disableCatchExceptions($client);
261276
$client->request('OPTIONS', '/', [], [], ['HTTP_Origin' => 'http://example.com']);
262277
$response = $client->getResponse();
263278
$this->assertSame(200, $response->getStatusCode());
@@ -267,21 +282,23 @@ public function testPreflightedRequestWhenDisabled(): void
267282
public function testUnAuthorizedMethod(): void
268283
{
269284
$client = static::createClient(['test_case' => 'connection']);
285+
$this->disableCatchExceptions($client);
270286
$client->request('PUT', '/', [], [], ['HTTP_Origin' => 'http://example.com']);
271287
$this->assertSame(405, $client->getResponse()->getStatusCode());
272288
}
273289

274290
public function testPreflightedRequestWhenEnabled(): void
275291
{
276292
$client = static::createClient(['test_case' => 'connectionWithCORS']);
293+
$this->disableCatchExceptions($client);
277294
$client->request('OPTIONS', '/batch', [], [], ['HTTP_Origin' => 'http://example.com']);
278295
$this->assertCORSHeadersExists($client);
279296
}
280297

281298
public function testNoCORSHeadersIfOriginHeaderNotExists(): void
282299
{
283300
$client = static::createClient(['test_case' => 'connectionWithCORS']);
284-
301+
$this->disableCatchExceptions($client);
285302
$client->request('GET', '/', ['query' => $this->friendsQuery], [], ['CONTENT_TYPE' => 'application/graphql']);
286303
$result = $client->getResponse()->getContent();
287304
$this->assertSame(['data' => $this->expectedData], \json_decode($result, true), $result);

0 commit comments

Comments
 (0)