Skip to content

Commit

Permalink
Add Symfony 5.0 Support (#23)
Browse files Browse the repository at this point in the history
* Symfony 5

* Add Symfony 5 supports

* Fix php cs

* change version

* fix test

* remove un-maintained versions

* Remove dev flag

* Add test coverage stage
  • Loading branch information
benji07 authored and mcg-web committed Nov 29, 2019
1 parent c3b7846 commit 74c8d84
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 124 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ composer.lock
composer.phar
.php_cs.cache
.php_cs
php-cs-fixer.phar
16 changes: 7 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,19 @@ matrix:
env: COMPOSER_UPDATE_FLAGS=--prefer-lowest
- php: 7.1
- php: 7.2
env: SYMFONY_VERSION=3.2.*
- php: 7.2
env: SYMFONY_VERSION=3.3.* TEST_COVERAGE=true
- php: 7.2
env: SYMFONY_VERSION=3.3.* GRAPHQLBUNDLE_VERSION=0.9.*
- php: 7.2
env: SYMFONY_VERSION=3.4.* GRAPHQLBUNDLE_VERSION=0.10.* DEPENDENCIES=dev
env: SYMFONY_VERSION=3.4.* GRAPHQLBUNDLE_VERSION=0.10.*
- php: 7.2
env: SYMFONY_VERSION=3.4.*
- php: 7.2
env: SYMFONY_VERSION=4.0.*
- php: 7.3
env: SYMFONY_VERSION=4.1.*
- php: 7.3
env: SYMFONY_VERSION=4.2.*
env: SYMFONY_VERSION=4.3.* TEST_COVERAGE=true
- php: 7.3
env: SYMFONY_VERSION=4.4.*
- php: 7.3
env: SYMFONY_VERSION=5.0.*
- php: nightly
env: COMPOSER_UPDATE_FLAGS=--ignore-platform-reqs
allow_failures:
Expand All @@ -55,7 +53,7 @@ install: composer update --prefer-source --no-interaction --optimize-autoloader

script:
- ./bin/phpunit --debug $( if [ "$TEST_COVERAGE" = "true" ]; then echo "-d xdebug.max_nesting_level=1000 --coverage-clover=build/logs/clover.xml"; fi; )
- 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;
- if [ "${TEST_COVERAGE}" = "true" ]; then composer check-cs; fi;

after_script:
- 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;
Expand Down
68 changes: 0 additions & 68 deletions Tests/DependencyInjection/OverblogGraphiQLExtensionTest.php

This file was deleted.

4 changes: 2 additions & 2 deletions Tests/Fixtures/TestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public function registerContainerConfiguration(LoaderInterface $loader)
$container->loadFromExtension('framework', [
'secret' => 'test',
'test' => true,
'templating' => ['engine' => ['twig']],
//'templating' => ['engine' => ['twig']],
'assets' => ['enabled' => false],
'router' => ['resource' => '%kernel.root_dir%/../Resources/config/routing.xml'],
'router' => ['resource' => '%kernel.project_dir%/Resources/config/routing.xml'],
]);
});
}
Expand Down
37 changes: 37 additions & 0 deletions Tests/ForwardCompatTestCaseTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Overblog\GraphiQLBundle\Tests;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

// see https://github.com/lexik/LexikJWTAuthenticationBundle/blob/master/Tests/Functional/ForwardCompatTestCaseTrait.php

if (70000 <= \PHP_VERSION_ID && (new \ReflectionMethod(WebTestCase::class, 'tearDown'))->hasReturnType()) {
eval('
namespace Overblog\GraphiQLBundle\Tests;
/**
* @internal
*/
trait ForwardCompatTestCaseTrait
{
protected function tearDown(): void
{
static::ensureKernelShutdown();
static::$kernel = null;
}
}
');
} else {
/**
* @internal
*/
trait ForwardCompatTestCaseTrait
{
protected function tearDown()
{
static::ensureKernelShutdown();
static::$kernel = null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,6 @@

final class GraphiQLControllerTest extends TestCase
{
public function testSecondSchema()
{
$client = static::createClient();

$client->request('GET', '/graphiql/secondFakeSchema');
$response = $client->getResponse();

$this->assertInstanceOf(Response::class, $response);
$this->assertSame(200, $response->getStatusCode());
$this->stringContains('Loading...', $response->getContent());
$this->stringContains('var endpoint = "\/graphql\/secondFakeSchema"', $response->getContent());
}

public function testDefaultSchema()
{
$client = static::createClient();
Expand Down
23 changes: 5 additions & 18 deletions Tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

abstract class TestCase extends WebTestCase
{
/** @var TestKernel[] */
private static $kernels = [];
use ForwardCompatTestCaseTrait;

/**
* {@inheritdoc}
Expand All @@ -23,27 +22,15 @@ protected static function getKernelClass()
*/
protected static function createKernel(array $options = [])
{
static::$class = static::getKernelClass();
if (null === static::$class) {
static::$class = static::getKernelClass();
}

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

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

$kernelKey = '//'.$env.'//'.var_export($debug, true);

if (!isset(self::$kernels[$kernelKey])) {
self::$kernels[$kernelKey] = new static::$class($env, $debug, $options['test_case']);
}

return self::$kernels[$kernelKey];
}

/**
* {@inheritdoc}
*/
protected function tearDown()
{
static::$kernel = null;
return new static::$class($env, $debug, $options['test_case']);
}
}
34 changes: 20 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,17 @@
"sort-packages": true
},
"require": {
"php": "^5.6 || ^7.0",
"symfony/http-foundation": "^3.2.2 || ^4.0",
"symfony/twig-bundle": "^3.2.10 || ^4.0",
"symfony/routing": "^3.2 || ^4.0"
"php": ">=5.6",
"symfony/framework-bundle": "^3.4 || ^4.0 || ^5.0",
"symfony/twig-bundle": "^3.4 || ^4.0 || ^5.0"
},
"require-dev": {
"overblog/graphql-bundle": "^0.9.0 || ^0.10.0",
"overblog/graphql-bundle": ">=0.9",
"phpunit/phpunit": "^5.7 || ^6.0",
"sensio/framework-extra-bundle": "^3.0 || ^4.0",
"symfony/browser-kit": "^3.2 || ^4.0",
"symfony/config": "^3.2 || ^4.0",
"symfony/console": "^3.2 || ^4.0",
"symfony/dependency-injection": "^3.2 || ^4.0",
"symfony/expression-language": "^3.2 || ^4.0",
"symfony/framework-bundle": "^3.2.2 || ^4.0",
"symfony/templating": "^3.2 || ^4.0",
"symfony/yaml": "^3.2 || ^4.0"
"sensio/framework-extra-bundle": "^3.0 || ^4.0 || ^5.0",
"symfony/browser-kit": "^3.4 || ^4.0 || ^5.0",
"symfony/templating": "^3.4 || ^4.0 || ^5.0",
"symfony/yaml": "^3.4 || ^4.0 || ^5.0"
},
"autoload": {
"psr-4": { "Overblog\\GraphiQLBundle\\": "" },
Expand All @@ -49,5 +43,17 @@
"branch-alias": {
"dev-master": "0.1-dev"
}
},
"scripts": {
"test": "bin/phpunit --color=always -v --debug",
"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",
"fix-cs": [
"@install-cs",
"@php php-cs-fixer.phar fix --diff -v --allow-risky=yes --ansi"
],
"check-cs": [
"@install-cs",
"@php php-cs-fixer.phar fix --dry-run --diff -v --allow-risky=yes --ansi"
]
}
}

0 comments on commit 74c8d84

Please sign in to comment.