Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
language: php

dist: trusty
sudo: false

language: php
git:
depth: 1

branches:
only:
Expand All @@ -10,39 +14,38 @@ branches:
matrix:
fast_finish: true
include:
- php: 5.5
env: SYMFONY_VERSION=2.8.*
- php: 5.6
env: SYMFONY_VERSION=3.1.*
- php: 7.0
env: SYMFONY_VERSION=3.2.*
- php: 7.1
env: SYMFONY_VERSION=3.3.* TEST_COVERAGE=true
- php: 7.1
env: GRAPHQLPHP_VERSION=0.10.0
- php: hhvm
env: SYMFONY_VERSION=3.4.* GRAPHQLPHP_VERSION=0.10.0 DEPENDENCIES=dev
- php: 7.1
env: SYMFONY_VERSION=4.0.* DEPENDENCIES=dev
- php: nightly
env: COMPOSER_UPDATE_FLAGS=--ignore-platform-reqs
allow_failures:
- php: nightly
env: COMPOSER_UPDATE_FLAGS=--ignore-platform-reqs

cache:
directories:
- $HOME/.composer/cache
- $HOME/.php_cs.cache

before_install:
- if [ "$DEPENDENCIES" = "dev" ]; then perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json; fi;
- if [ ${TEST_COVERAGE} != true ]; then phpenv config-rm xdebug.ini || true; fi
- composer selfupdate
- if [ $SYMFONY_VERSION ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" "symfony/framework-bundle:${SYMFONY_VERSION}" --dev --no-update; fi;
- if [ $SYMFONY_VERSION ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --dev --no-update; fi;
- if [ $GRAPHQLPHP_VERSION ]; then composer require "webonyx/graphql-php:${GRAPHQLPHP_VERSION}" --dev --no-update; fi;

install: composer update --prefer-source --no-interaction --optimize-autoloader ${COMPOSER_UPDATE_FLAGS}

script:
- bin/phpunit --debug $( if [ $TEST_COVERAGE = true ]; then echo "-d xdebug.max_nesting_level=1000 --coverage-clover=build/logs/clover.xml"; fi; )
- if [ ${TRAVIS_PHP_VERSION} == "7.0" ]; then bin/php-cs-fixer fix --diff --dry-run -v; fi;
- if [ ${TRAVIS_PHP_VERSION} == "7.0" ]; then composer require --dev 'friendsofphp/php-cs-fixer:^2.0' && bin/php-cs-fixer fix --diff --dry-run -v; fi;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! Let's make it run on 7.1 instead for speed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove it from requirements because it seems to not be compatible with Symfony 4


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
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ Giving some love to PHP CS
---------------------------

```bash
bin/php-cs-fixer fix ./
composer require --dev 'friendsofphp/php-cs-fixer:^2.0'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcg-web how about creating a composer script to install and run the php cs?

composer cs-fix

Could even do a composer test as well for the phpunit call

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not against, we will dedicate a PR to this

bin/php-cs-fixer fix
```
6 changes: 5 additions & 1 deletion DependencyInjection/OverblogGraphQLExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,16 @@ private function setVersions(array $config, ContainerBuilder $container)

private function setConfigBuilders(array $config, ContainerBuilder $container)
{
$useObjectToAddResource = method_exists($container, 'addObjectResource');
$objectToAddResourceMethod = $useObjectToAddResource ? 'addObjectResource' : 'addClassResource';

foreach (['args', 'field'] as $category) {
if (!empty($config['definitions']['builders'][$category])) {
$method = 'add'.ucfirst($category).'BuilderClass';

foreach ($config['definitions']['builders'][$category] as $params) {
$container->addClassResource(new \ReflectionClass($params['class']));
$object = $useObjectToAddResource ? $params['class'] : new \ReflectionClass($params['class']);
$container->$objectToAddResourceMethod($object);
TypeWithOutputFieldsDefinition::$method($params['alias'], $params['class']);
}
}
Expand Down
27 changes: 27 additions & 0 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ services:

overblog_graphql.request_executor:
class: Overblog\GraphQLBundle\Request\Executor
public: true
arguments:
- "@overblog_graphql.executor"
- "@event_dispatcher"
Expand All @@ -28,8 +29,14 @@ services:
- ["setMaxQueryComplexity", ["%overblog_graphql.query_max_complexity%"]]
- ["setMaxQueryDepth", ["%overblog_graphql.query_max_depth%"]]

Overblog\GraphQLBundle\Request\Executor:
alias: overblog_graphql.request_executor

overblog_graphql.request_parser:
class: Overblog\GraphQLBundle\Request\Parser
public: true



overblog_graphql.request_batch_parser:
class: Overblog\GraphQLBundle\Request\BatchParser
Expand All @@ -43,20 +50,36 @@ services:

overblog_graphql.type_resolver:
class: Overblog\GraphQLBundle\Resolver\TypeResolver
public: true
arguments:
-

Overblog\GraphQLBundle\Resolver\TypeResolver:
alias: overblog_graphql.type_resolver

overblog_graphql.resolver_resolver:
class: Overblog\GraphQLBundle\Resolver\ResolverResolver
public: true

Overblog\GraphQLBundle\Resolver\ResolverResolver:
alias: overblog_graphql.resolver_resolver

overblog_graphql.mutation_resolver:
class: Overblog\GraphQLBundle\Resolver\MutationResolver
public: true

Overblog\GraphQLBundle\Resolver\MutationResolver:
alias: overblog_graphql.mutation_resolver

overblog_graphql.access_resolver:
class: Overblog\GraphQLBundle\Resolver\AccessResolver
public: true
arguments:
- "@overblog_graphql.promise_adapter"

Overblog\GraphQLBundle\Resolver\AccessResolver:
alias: overblog_graphql.access_resolver

overblog_graphql.expression_language.default:
class: Overblog\GraphQLBundle\ExpressionLanguage\ExpressionLanguage
public: false
Expand All @@ -68,6 +91,7 @@ services:

overblog_graphql.cache_compiler:
class: Overblog\GraphQLBundle\Generator\TypeGenerator
public: true
arguments:
- "%overblog_graphql.class_namespace%"
- ["%overblog_graphql.resources_dir%/skeleton"]
Expand All @@ -81,6 +105,7 @@ services:

overblog_graphql.event_listener.request_file_listener:
class: Overblog\GraphQLBundle\EventListener\RequestFilesListener
public: true
arguments:
- "@request_stack"
tags:
Expand All @@ -106,6 +131,7 @@ services:

overblog_graphql.command.dump_schema:
class: Overblog\GraphQLBundle\Command\GraphQLDumpSchemaCommand
public: true
arguments:
# "overblog_graphql.request_executor" service must be load lazy since that command service
# is instanced before ClassLoaderEvent. This issues is fix in Symfony 3.4 introducing lazy commands
Expand All @@ -118,6 +144,7 @@ services:

overblog_graphql.command.debug:
class: Overblog\GraphQLBundle\Command\DebugCommand
public: true
arguments:
- "@overblog_graphql.type_resolver"
- "@overblog_graphql.mutation_resolver"
Expand Down
9 changes: 7 additions & 2 deletions Tests/Functional/App/TestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public function __construct($environment, $debug, $testCase = null)

public function getCacheDir()
{
return sys_get_temp_dir().'/OverblogGraphQLBundle/'.Kernel::VERSION.'/'.$this->testCase.'/cache/'.$this->environment;
return $this->basePath().'cache/'.$this->environment;
}

public function getLogDir()
{
return sys_get_temp_dir().'/OverblogGraphQLBundle/'.Kernel::VERSION.'/'.$this->testCase.'/logs';
return $this->basePath().'logs';
}

public function getRootDir()
Expand All @@ -63,4 +63,9 @@ public function registerContainerConfiguration(LoaderInterface $loader)
$loader->load(__DIR__.'/config/config.yml');
}
}

private function basePath()
{
return sys_get_temp_dir().'/OverblogGraphQLBundle/'.Kernel::VERSION.'/'.($this->testCase ? $this->testCase.'/' : '');
}
}
1 change: 1 addition & 0 deletions Tests/Functional/App/config/global/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ imports:
services:
overblog_graphql.test.resolver.global:
class: Overblog\GraphQLBundle\Tests\Functional\App\Resolver\GlobalResolver
public: true
arguments:
- "@overblog_graphql.type_resolver"

Expand Down
5 changes: 0 additions & 5 deletions Tests/Functional/Exception/ExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@

use Overblog\GraphQLBundle\Tests\Functional\TestCase;

/**
* Class ConnectionTest.
*
* @see https://github.com/graphql/graphql-relay-js/blob/master/src/connection/__tests__/connection.js
*/
class ExceptionTest extends TestCase
{
protected function setUp()
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/Security/AccessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function setUp()
$loader = new ClassLoader();
$loader->addPsr4(
'Overblog\\GraphQLBundle\\Access\\__DEFINITIONS__\\',
'/tmp/OverblogGraphQLBundle/'.Kernel::VERSION.'/access/cache/overbloggraphbundletestaccess/overblog/graphql-bundle/__definitions__'
'/tmp/OverblogGraphQLBundle/'.Kernel::VERSION.'/access/cache/testaccess/overblog/graphql-bundle/__definitions__'
);
$loader->register();
$this->loader = $loader;
Expand Down
14 changes: 2 additions & 12 deletions Tests/Functional/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ abstract class TestCase extends WebTestCase
const ANONYMOUS_USER = null;
const DEFAULT_PASSWORD = '123';

/** @var TestKernel[] */
private static $kernels = [];

/**
* {@inheritdoc}
*/
Expand All @@ -39,17 +36,10 @@ protected static function createKernel(array $options = [])

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

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

$kernelKey = $options['test_case'] ?: '__default__';
$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];
return new static::$class($env, $debug, $options['test_case']);
}

/**
Expand Down
36 changes: 19 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@
"sort-packages": true
},
"require": {
"php": ">=5.5.9",
"php": ">=5.6",
"doctrine/doctrine-cache-bundle": "^1.2",
"overblog/graphql-php-generator": "^0.5.0",
"symfony/cache": "^3.1",
"symfony/expression-language": "^2.8 || ^3.0",
"symfony/framework-bundle": "^2.8 || ^3.0",
"symfony/options-resolver": "^2.8 || ^3.0",
"symfony/property-access": "^2.8 || ^3.0",
"symfony/cache": "^3.1 || ^4.0",
"symfony/config": "^3.1 || ^4.0",
"symfony/dependency-injection": "^3.1 || ^4.0",
"symfony/expression-language": "^3.1 || ^4.0",
"symfony/framework-bundle": "^3.1 || ^4.0",
"symfony/options-resolver": "^3.1 || ^4.0",
"symfony/property-access": "^3.1 || ^4.0",
"webonyx/graphql-php": "^0.10.0 || ^0.11.0"
},
"suggest": {
Expand All @@ -45,20 +47,20 @@
"react/promise": "To use ReactPHP promise adapter"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.0",
"phpunit/phpunit": "^4.1 || ^5.5 || ^6.0",
"react/promise": "^2.5",
"sensio/framework-extra-bundle": "^3.0",
"symfony/asset": "^2.8 || ^3.0",
"symfony/browser-kit": "^2.8 || ^3.0",
"symfony/css-selector": "^2.8 || ^3.0",
"symfony/dependency-injection": "^2.8 || ^3.0",
"symfony/phpunit-bridge": "^2.8 || ^3.0",
"symfony/security-bundle": "^2.8 || ^3.0",
"symfony/templating": "^2.8 || ^3.0",
"symfony/twig-bundle": "^2.8 || ^3.0",
"symfony/web-profiler-bundle": "^2.8 || ^3.0",
"symfony/yaml": "^2.8 || ^3.0"
"symfony/asset": "^3.1 || ^4.0",
"symfony/browser-kit": "^3.1 || ^4.0",
"symfony/console": "^3.1 || ^4.0",
"symfony/css-selector": "^3.1 || ^4.0",
"symfony/phpunit-bridge": "^3.1 || ^4.0",
"symfony/process": "^3.1 || ^4.0",
"symfony/security-bundle": "^3.1 || ^4.0",
"symfony/templating": "^3.1 || ^4.0",
"symfony/twig-bundle": "^3.1 || ^4.0",
"symfony/web-profiler-bundle": "^3.1 || ^4.0",
"symfony/yaml": "^3.1 || ^4.0"
},
"extra": {
"branch-alias": {
Expand Down