Skip to content

Commit 869794a

Browse files
authored
Merge pull request overblog#621 from mcg-web/symfony_5
Add support for Symfony 5
2 parents ea58a4e + e653f4c commit 869794a

12 files changed

+107
-41
lines changed

.travis.yml

+6-15
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,18 @@ jobs:
4444
env: SYMFONY_VERSION=3.4.*
4545
- php: 7.3
4646
env: SYMFONY_VERSION=4.1.*
47-
- php: 7.3
48-
env: SYMFONY_VERSION=4.2.*
49-
- php: 7.3
50-
env: SYMFONY_VERSION=4.3.* SYMFONY_DEPRECATIONS_HELPER=max[total]=0
51-
- php: 7.3
52-
env: SYMFONY_VERSION=4.4.* STABILITY=dev SYMFONY_DEPRECATIONS_HELPER=max[total]=0
53-
- php: 7.3
54-
env: SYMFONY_VERSION=5.0.* STABILITY=dev SYMFONY_DEPRECATIONS_HELPER=max[total]=0
5547
- php: 7.4snapshot
5648
env: SYMFONY_VERSION=4.3.*
49+
- php: 7.3
50+
env: SYMFONY_VERSION=4.4.* SYMFONY_DEPRECATIONS_HELPER=max[total]=0
51+
- php: 7.3
52+
env: SYMFONY_VERSION=5.0.* SYMFONY_DEPRECATIONS_HELPER=max[total]=0
5753
- php: nightly
5854
env: COMPOSER_UPDATE_FLAGS=--ignore-platform-reqs
5955

6056
- stage: Code Quality
6157
php: 7.2
62-
env: COVERAGE
58+
env: COVERAGE SYMFONY_VERSION=4.4.*
6359
before_script:
6460
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,}
6561
- if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi
@@ -70,7 +66,7 @@ jobs:
7066

7167
- stage: Code Quality
7268
php: 7.2
73-
env: STATIC_ANALYSIS
69+
env: STATIC_ANALYSIS SYMFONY_VERSION=4.3.*
7470
install: travis_retry composer install --prefer-dist
7571
script: composer static-analysis
7672

@@ -86,8 +82,3 @@ jobs:
8682

8783
allow_failures:
8884
- php: nightly
89-
- php: 7.4snapshot
90-
- php: 7.3
91-
env: SYMFONY_VERSION=4.4.* STABILITY=dev SYMFONY_DEPRECATIONS_HELPER=max[total]=0
92-
- php: 7.3
93-
env: SYMFONY_VERSION=5.0.* STABILITY=dev SYMFONY_DEPRECATIONS_HELPER=max[total]=0

composer.json

+15-15
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
"require": {
3131
"php": ">=5.6",
3232
"psr/log": "^1.0",
33-
"symfony/config": "^3.1 || ^4.0",
34-
"symfony/dependency-injection": "^3.1 || ^4.0",
35-
"symfony/event-dispatcher": "^3.1 || ^4.0",
36-
"symfony/expression-language": "^3.1 || ^4.0",
37-
"symfony/framework-bundle": "^3.1 || ^4.0",
38-
"symfony/options-resolver": "^3.1 || ^4.0",
39-
"symfony/property-access": "^3.1 || ^4.0",
33+
"symfony/config": "^3.1 || ^4.0 || ^5.0",
34+
"symfony/dependency-injection": "^3.1 || ^4.0 || ^5.0",
35+
"symfony/event-dispatcher": "^3.1 || ^4.0 || ^5.0",
36+
"symfony/expression-language": "^3.1 || ^4.0 || ^5.0",
37+
"symfony/framework-bundle": "^3.1 || ^4.0 || ^5.0",
38+
"symfony/options-resolver": "^3.1 || ^4.0 || ^5.0",
39+
"symfony/property-access": "^3.1 || ^4.0 || ^5.0",
4040
"webonyx/graphql-php": "^0.11.2 || ^0.12.0 || ^0.13.0"
4141
},
4242
"replace": {
@@ -50,14 +50,14 @@
5050
"require-dev": {
5151
"phpunit/phpunit": "^5.7.26 || ^6.0 || ^7.2",
5252
"react/promise": "^2.5",
53-
"symfony/asset": "^3.1 || ^4.0",
54-
"symfony/browser-kit": "^3.1 || ^4.0",
55-
"symfony/console": "^3.1 || ^4.0",
56-
"symfony/css-selector": "^3.1 || ^4.0",
57-
"symfony/phpunit-bridge": "^3.1 || ^4.0",
58-
"symfony/process": "^3.1 || ^4.0",
59-
"symfony/security-bundle": "^3.1 || ^4.0",
60-
"symfony/yaml": "^3.1 || ^4.0"
53+
"symfony/asset": "^3.1 || ^4.0 || ^5.0",
54+
"symfony/browser-kit": "^3.1 || ^4.0 || ^5.0",
55+
"symfony/console": "^3.1 || ^4.0 || ^5.0",
56+
"symfony/css-selector": "^3.1 || ^4.0 || ^5.0",
57+
"symfony/phpunit-bridge": "^3.1 || ^4.0 || ^5.0",
58+
"symfony/process": "^3.1 || ^4.0 || ^5.0",
59+
"symfony/security-bundle": "^3.1 || ^4.0 || ^5.0",
60+
"symfony/yaml": "^3.1 || ^4.0 || ^5.0"
6161
},
6262
"extra": {
6363
"branch-alias": {

src/Command/CompileCommand.php

+2
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
4141
}
4242
$io->table(['class', 'path'], $rows);
4343
}
44+
45+
return 0;
4446
}
4547
}

src/Command/DebugCommand.php

+2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
7777
$resolver = $this->{$category.'Resolver'};
7878
$this->renderTable($resolver, $tableHeaders, $io);
7979
}
80+
81+
return 0;
8082
}
8183

8284
/**

src/Command/GraphQLDumpSchemaCommand.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
6868
$io = new SymfonyStyle($input, $output);
6969
$file = $this->createFile($input);
7070
$io->success(\sprintf('GraphQL schema "%s" was successfully dumped.', \realpath($file)));
71+
72+
return 0;
7173
}
7274

7375
private function createFile(InputInterface $input)
7476
{
7577
$format = \strtolower($input->getOption('format'));
7678
$schemaName = $input->getOption('schema');
7779

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

8082
switch ($format) {
8183
case 'json':

src/Resources/config/services.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ services:
138138
class: Overblog\GraphQLBundle\Command\GraphQLDumpSchemaCommand
139139
public: true
140140
arguments:
141-
- "%kernel.root_dir%"
141+
- "%kernel.cache_dir%/../.."
142142
calls:
143143
# "overblog_graphql.request_executor" service must be load lazy since that command service
144144
# is instanced before ClassLoaderEvent. This issues is fix in Symfony 3.4 introducing lazy commands

tests/Config/Parser/GraphQLParserTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Overblog\GraphQLBundle\Config\Parser\GraphQL\ASTConverter\CustomScalarNode;
66
use Overblog\GraphQLBundle\Config\Parser\GraphQLParser;
77
use Overblog\GraphQLBundle\Tests\VersionHelper;
8-
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
8+
use PHPUnit\Framework\TestCase;
99
use Symfony\Component\DependencyInjection\ContainerBuilder;
1010
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
1111

tests/Functional/App/TestKernel.php

+16
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)
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/Controller/GraphControllerTest.php

+9
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public function graphQLEndpointUriProvider()
8585
public function testEndpointWithEmptyQuery()
8686
{
8787
$client = static::createClient();
88+
$this->disableCatchExceptions($client);
8889
$client->request('GET', '/', []);
8990
$client->getResponse()->getContent();
9091
}
@@ -96,6 +97,7 @@ public function testEndpointWithEmptyQuery()
9697
public function testEndpointWithEmptyJsonBodyQuery()
9798
{
9899
$client = static::createClient();
100+
$this->disableCatchExceptions($client);
99101
$client->request('GET', '/', [], [], ['CONTENT_TYPE' => 'application/json']);
100102
$client->getResponse()->getContent();
101103
}
@@ -107,6 +109,7 @@ public function testEndpointWithEmptyJsonBodyQuery()
107109
public function testEndpointWithInvalidBodyQuery()
108110
{
109111
$client = static::createClient();
112+
$this->disableCatchExceptions($client);
110113
$client->request('GET', '/', [], [], ['CONTENT_TYPE' => 'application/json'], '{');
111114
$client->getResponse()->getContent();
112115
}
@@ -143,6 +146,7 @@ public function testEndpointActionWithVariables()
143146
public function testEndpointActionWithInvalidVariables()
144147
{
145148
$client = static::createClient(['test_case' => 'connection']);
149+
$this->disableCatchExceptions($client);
146150

147151
$query = <<<'EOF'
148152
query {
@@ -160,6 +164,7 @@ public function testEndpointActionWithInvalidVariables()
160164
public function testMultipleEndpointActionWithUnknownSchemaName()
161165
{
162166
$client = static::createClient(['test_case' => 'connection']);
167+
$this->disableCatchExceptions($client);
163168

164169
$query = <<<'EOF'
165170
query {
@@ -225,6 +230,7 @@ public function graphQLBatchEndpointUriProvider()
225230
public function testBatchEndpointWithEmptyQuery()
226231
{
227232
$client = static::createClient();
233+
$this->disableCatchExceptions($client);
228234
$client->request('GET', '/batch', [], [], ['CONTENT_TYPE' => 'application/json'], '{}');
229235
$client->getResponse()->getContent();
230236
}
@@ -236,6 +242,7 @@ public function testBatchEndpointWithEmptyQuery()
236242
public function testBatchEndpointWrongContentType()
237243
{
238244
$client = static::createClient();
245+
$this->disableCatchExceptions($client);
239246
$client->request('GET', '/batch');
240247
$client->getResponse()->getContent();
241248
}
@@ -247,6 +254,7 @@ public function testBatchEndpointWrongContentType()
247254
public function testBatchEndpointWithInvalidJson()
248255
{
249256
$client = static::createClient();
257+
$this->disableCatchExceptions($client);
250258
$client->request('GET', '/batch', [], [], ['CONTENT_TYPE' => 'application/json'], '{');
251259
$client->getResponse()->getContent();
252260
}
@@ -258,6 +266,7 @@ public function testBatchEndpointWithInvalidJson()
258266
public function testBatchEndpointWithInvalidQuery()
259267
{
260268
$client = static::createClient();
269+
$this->disableCatchExceptions($client);
261270
$client->request('GET', '/batch', [], [], ['CONTENT_TYPE' => 'application/json'], '{"test" : {"query": 1}}');
262271
$client->getResponse()->getContent();
263272
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace Overblog\GraphQLBundle\Tests\Functional;
4+
5+
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6+
7+
// see https://github.com/lexik/LexikJWTAuthenticationBundle/blob/master/Tests/Functional/ForwardCompatTestCaseTrait.php
8+
9+
if (70000 <= \PHP_VERSION_ID && (new \ReflectionMethod(WebTestCase::class, 'tearDown'))->hasReturnType()) {
10+
eval('
11+
namespace Overblog\GraphQLBundle\Tests\Functional;
12+
13+
/**
14+
* @internal
15+
*/
16+
trait ForwardCompatTestCaseTrait
17+
{
18+
protected function tearDown(): void
19+
{
20+
static::ensureKernelShutdown();
21+
static::$kernel = null;
22+
}
23+
}
24+
');
25+
} else {
26+
/**
27+
* @internal
28+
*/
29+
trait ForwardCompatTestCaseTrait
30+
{
31+
protected function tearDown()
32+
{
33+
static::ensureKernelShutdown();
34+
static::$kernel = null;
35+
}
36+
}
37+
}

tests/Functional/TestCase.php

+14-8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717
abstract class TestCase extends WebTestCase
1818
{
19+
use ForwardCompatTestCaseTrait;
20+
1921
const USER_RYAN = 'ryan';
2022
const USER_ADMIN = 'admin';
2123
const ANONYMOUS_USER = null;
@@ -55,14 +57,6 @@ public static function setUpBeforeClass()
5557
$fs->remove(\sys_get_temp_dir().'/OverblogGraphQLBundle/');
5658
}
5759

58-
/**
59-
* {@inheritdoc}
60-
*/
61-
protected function tearDown()
62-
{
63-
static::$kernel = null;
64-
}
65-
6660
protected static function executeGraphQLRequest($query, $rootValue = [], $schemaName = null)
6761
{
6862
$request = new Request();
@@ -106,6 +100,8 @@ protected static function query($query, $username, $testCase, $password = self::
106100

107101
protected static function createClientAuthenticated($username, $testCase, $password = self::DEFAULT_PASSWORD)
108102
{
103+
static::ensureKernelShutdown();
104+
static::$kernel = null;
109105
$client = static::createClient(['test_case' => $testCase]);
110106

111107
if ($username) {
@@ -154,4 +150,14 @@ public static function expressionFunctionFromPhp($phpFunctionName)
154150
return \sprintf('\%s(%s)', $phpFunctionName, \implode(', ', \func_get_args()));
155151
});
156152
}
153+
154+
/**
155+
* @param Client|KernelBrowser $client
156+
*/
157+
protected function disableCatchExceptions($client)
158+
{
159+
if (\is_callable([$client, 'catchExceptions'])) {
160+
$client->catchExceptions(false);
161+
}
162+
}
157163
}

tests/Functional/Upload/UploadTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ private function assertUpload(array $expected, array $parameters, array $files,
162162
private function uploadRequest(array $parameters, array $files, $uri = '/')
163163
{
164164
$client = static::createClient(['test_case' => 'upload']);
165+
$this->disableCatchExceptions($client);
165166
$client->request(
166167
'POST',
167168
$uri,

0 commit comments

Comments
 (0)