Skip to content

Commit 74c8d84

Browse files
benji07mcg-web
authored andcommitted
Add Symfony 5.0 Support (#23)
* Symfony 5 * Add Symfony 5 supports * Fix php cs * change version * fix test * remove un-maintained versions * Remove dev flag * Add test coverage stage
1 parent c3b7846 commit 74c8d84

File tree

8 files changed

+72
-124
lines changed

8 files changed

+72
-124
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ composer.lock
66
composer.phar
77
.php_cs.cache
88
.php_cs
9+
php-cs-fixer.phar

.travis.yml

+7-9
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,19 @@ matrix:
1919
env: COMPOSER_UPDATE_FLAGS=--prefer-lowest
2020
- php: 7.1
2121
- php: 7.2
22-
env: SYMFONY_VERSION=3.2.*
23-
- php: 7.2
24-
env: SYMFONY_VERSION=3.3.* TEST_COVERAGE=true
25-
- php: 7.2
26-
env: SYMFONY_VERSION=3.3.* GRAPHQLBUNDLE_VERSION=0.9.*
27-
- php: 7.2
28-
env: SYMFONY_VERSION=3.4.* GRAPHQLBUNDLE_VERSION=0.10.* DEPENDENCIES=dev
22+
env: SYMFONY_VERSION=3.4.* GRAPHQLBUNDLE_VERSION=0.10.*
2923
- php: 7.2
3024
env: SYMFONY_VERSION=3.4.*
3125
- php: 7.2
3226
env: SYMFONY_VERSION=4.0.*
3327
- php: 7.3
3428
env: SYMFONY_VERSION=4.1.*
3529
- php: 7.3
36-
env: SYMFONY_VERSION=4.2.*
30+
env: SYMFONY_VERSION=4.3.* TEST_COVERAGE=true
31+
- php: 7.3
32+
env: SYMFONY_VERSION=4.4.*
33+
- php: 7.3
34+
env: SYMFONY_VERSION=5.0.*
3735
- php: nightly
3836
env: COMPOSER_UPDATE_FLAGS=--ignore-platform-reqs
3937
allow_failures:
@@ -55,7 +53,7 @@ install: composer update --prefer-source --no-interaction --optimize-autoloader
5553

5654
script:
5755
- ./bin/phpunit --debug $( if [ "$TEST_COVERAGE" = "true" ]; then echo "-d xdebug.max_nesting_level=1000 --coverage-clover=build/logs/clover.xml"; fi; )
58-
- if [ "${TEST_COVERAGE}" = "true" ]; then wget http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -O php-cs-fixer && php ./php-cs-fixer fix --diff --dry-run -v; fi;
56+
- if [ "${TEST_COVERAGE}" = "true" ]; then composer check-cs; fi;
5957

6058
after_script:
6159
- if [ "${TEST_COVERAGE}" = "true" ]; then wget https://scrutinizer-ci.com/ocular.phar && travis_retry php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml; fi;

Tests/DependencyInjection/OverblogGraphiQLExtensionTest.php

-68
This file was deleted.

Tests/Fixtures/TestKernel.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ public function registerContainerConfiguration(LoaderInterface $loader)
2929
$container->loadFromExtension('framework', [
3030
'secret' => 'test',
3131
'test' => true,
32-
'templating' => ['engine' => ['twig']],
32+
//'templating' => ['engine' => ['twig']],
3333
'assets' => ['enabled' => false],
34-
'router' => ['resource' => '%kernel.root_dir%/../Resources/config/routing.xml'],
34+
'router' => ['resource' => '%kernel.project_dir%/Resources/config/routing.xml'],
3535
]);
3636
});
3737
}

Tests/ForwardCompatTestCaseTrait.php

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace Overblog\GraphiQLBundle\Tests;
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\GraphiQLBundle\Tests;
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/Integration/OverblogGraphQLBundle/Controller/GraphiQLControllerTest.php

-13
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,6 @@
77

88
final class GraphiQLControllerTest extends TestCase
99
{
10-
public function testSecondSchema()
11-
{
12-
$client = static::createClient();
13-
14-
$client->request('GET', '/graphiql/secondFakeSchema');
15-
$response = $client->getResponse();
16-
17-
$this->assertInstanceOf(Response::class, $response);
18-
$this->assertSame(200, $response->getStatusCode());
19-
$this->stringContains('Loading...', $response->getContent());
20-
$this->stringContains('var endpoint = "\/graphql\/secondFakeSchema"', $response->getContent());
21-
}
22-
2310
public function testDefaultSchema()
2411
{
2512
$client = static::createClient();

Tests/TestCase.php

+5-18
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
abstract class TestCase extends WebTestCase
99
{
10-
/** @var TestKernel[] */
11-
private static $kernels = [];
10+
use ForwardCompatTestCaseTrait;
1211

1312
/**
1413
* {@inheritdoc}
@@ -23,27 +22,15 @@ protected static function getKernelClass()
2322
*/
2423
protected static function createKernel(array $options = [])
2524
{
26-
static::$class = static::getKernelClass();
25+
if (null === static::$class) {
26+
static::$class = static::getKernelClass();
27+
}
2728

2829
$options['test_case'] = isset($options['test_case']) ? $options['test_case'] : 'default';
2930

3031
$env = isset($options['environment']) ? $options['environment'] : 'overbloggraphibundletest'.strtolower($options['test_case']);
3132
$debug = isset($options['debug']) ? $options['debug'] : true;
3233

33-
$kernelKey = '//'.$env.'//'.var_export($debug, true);
34-
35-
if (!isset(self::$kernels[$kernelKey])) {
36-
self::$kernels[$kernelKey] = new static::$class($env, $debug, $options['test_case']);
37-
}
38-
39-
return self::$kernels[$kernelKey];
40-
}
41-
42-
/**
43-
* {@inheritdoc}
44-
*/
45-
protected function tearDown()
46-
{
47-
static::$kernel = null;
34+
return new static::$class($env, $debug, $options['test_case']);
4835
}
4936
}

composer.json

+20-14
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,17 @@
2121
"sort-packages": true
2222
},
2323
"require": {
24-
"php": "^5.6 || ^7.0",
25-
"symfony/http-foundation": "^3.2.2 || ^4.0",
26-
"symfony/twig-bundle": "^3.2.10 || ^4.0",
27-
"symfony/routing": "^3.2 || ^4.0"
24+
"php": ">=5.6",
25+
"symfony/framework-bundle": "^3.4 || ^4.0 || ^5.0",
26+
"symfony/twig-bundle": "^3.4 || ^4.0 || ^5.0"
2827
},
2928
"require-dev": {
30-
"overblog/graphql-bundle": "^0.9.0 || ^0.10.0",
29+
"overblog/graphql-bundle": ">=0.9",
3130
"phpunit/phpunit": "^5.7 || ^6.0",
32-
"sensio/framework-extra-bundle": "^3.0 || ^4.0",
33-
"symfony/browser-kit": "^3.2 || ^4.0",
34-
"symfony/config": "^3.2 || ^4.0",
35-
"symfony/console": "^3.2 || ^4.0",
36-
"symfony/dependency-injection": "^3.2 || ^4.0",
37-
"symfony/expression-language": "^3.2 || ^4.0",
38-
"symfony/framework-bundle": "^3.2.2 || ^4.0",
39-
"symfony/templating": "^3.2 || ^4.0",
40-
"symfony/yaml": "^3.2 || ^4.0"
31+
"sensio/framework-extra-bundle": "^3.0 || ^4.0 || ^5.0",
32+
"symfony/browser-kit": "^3.4 || ^4.0 || ^5.0",
33+
"symfony/templating": "^3.4 || ^4.0 || ^5.0",
34+
"symfony/yaml": "^3.4 || ^4.0 || ^5.0"
4135
},
4236
"autoload": {
4337
"psr-4": { "Overblog\\GraphiQLBundle\\": "" },
@@ -49,5 +43,17 @@
4943
"branch-alias": {
5044
"dev-master": "0.1-dev"
5145
}
46+
},
47+
"scripts": {
48+
"test": "bin/phpunit --color=always -v --debug",
49+
"install-cs": "test -f php-cs-fixer.phar || wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.15.3/php-cs-fixer.phar -O php-cs-fixer.phar",
50+
"fix-cs": [
51+
"@install-cs",
52+
"@php php-cs-fixer.phar fix --diff -v --allow-risky=yes --ansi"
53+
],
54+
"check-cs": [
55+
"@install-cs",
56+
"@php php-cs-fixer.phar fix --dry-run --diff -v --allow-risky=yes --ansi"
57+
]
5258
}
5359
}

0 commit comments

Comments
 (0)