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
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ matrix:
- php: 5.6
env: SYMFONY_VERSION=3.1.* SYMFONY_DEPRECATIONS_HELPER=disabled
- php: 7.0
env: SYMFONY_VERSION=3.2.*
env: SYMFONY_VERSION=3.2.* PHPUNIT_VERSION=^5.7.26
- php: 7.1
- php: 7.2
env: PHP_CS_FIXER=true
Expand All @@ -30,12 +30,10 @@ matrix:
- php: 7.2
env: SYMFONY_VERSION=4.0.* TEST_COVERAGE=true
- php: 7.2
env: SYMFONY_VERSION=4.1.* DEPENDENCIES=dev
env: SYMFONY_VERSION=4.1.* STABILITY=beta
- php: nightly
env: COMPOSER_UPDATE_FLAGS=--ignore-platform-reqs
allow_failures:
- php: 7.2
env: SYMFONY_VERSION=4.1.* DEPENDENCIES=dev
- php: nightly
env: COMPOSER_UPDATE_FLAGS=--ignore-platform-reqs

Expand All @@ -46,15 +44,17 @@ cache:
- vendor/

before_install:
- if [ ${DEPENDENCIES} = "dev" ]; then perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json; fi;
- if [ "${STABILITY}" != "" ]; then perl -pi -e 's/^}$/,"minimum-stability":"'"${STABILITY}"'"}/' composer.json; fi;
- if [ "${SYMFONY_VERSION}" != "" ]; then perl -pi -e 's#"(symfony/.*)":\s*".*"#"$1":"'"${SYMFONY_VERSION}"'"#' composer.json; fi;
- if [ "${PHPUNIT_VERSION}" != "" ]; then composer req "phpunit/phpunit:${PHPUNIT_VERSION}" --dev --no-update; 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}" --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:
- composer validate --no-check-lock --strict
- bin/phpunit --debug $( if [ $TEST_COVERAGE = true ]; then echo "-d xdebug.max_nesting_level=1000 --coverage-clover=build/logs/clover.xml"; fi; )
- if [ ${PHP_CS_FIXER} = true ]; then composer require --dev 'friendsofphp/php-cs-fixer:^2.0' && bin/php-cs-fixer fix --diff --dry-run -v; fi;

Expand Down
35 changes: 24 additions & 11 deletions DependencyInjection/OverblogGraphQLTypesExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,44 +41,57 @@ class OverblogGraphQLTypesExtension extends Extension

public function load(array $configs, ContainerBuilder $container)
{
$this->checkTypesDuplication($configs);
// flatten config is a requirement to support inheritance
$flattenConfig = [call_user_func_array('array_merge', $configs)];
$configuration = $this->getConfiguration($flattenConfig, $container);
$config = $this->processConfiguration($configuration, $flattenConfig);
$configs = array_filter($configs);
//$configs = array_filter($configs);
if (count($configs) > 1) {
throw new \InvalidArgumentException('Configs type should never contain more than one config to deal with inheritance.');
}
$configuration = $this->getConfiguration($configs, $container);
$config = $this->processConfiguration($configuration, $configs);

$container->setParameter($this->getAlias().'.config', $config);
}

public function containerPrependExtensionConfig(array $config, ContainerBuilder $container)
public function containerPrependExtensionConfig(array $configs, ContainerBuilder $container)
{
$typesMappings = $this->mappingConfig($config, $container);
$typesMappings = $this->mappingConfig($configs, $container);
// reset treated files
$this->treatedFiles = [];
$typesMappings = call_user_func_array('array_merge', $typesMappings);
$typeConfigs = [];
// treats mappings
foreach ($typesMappings as $params) {
$this->prependExtensionConfigFromFiles($params['type'], $params['files'], $container);
$typeConfigs = array_merge($typeConfigs, $this->parseTypeConfigFiles($params['type'], $params['files'], $container));
}

$this->checkTypesDuplication($typeConfigs);
// flatten config is a requirement to support inheritance
$flattenTypeConfig = call_user_func_array('array_merge', $typeConfigs);

$container->prependExtensionConfig($this->getAlias(), $flattenTypeConfig);
}

/**
* @param $type
* @param SplFileInfo[] $files
* @param ContainerBuilder $container
*
* @return array
*/
private function prependExtensionConfigFromFiles($type, $files, ContainerBuilder $container)
private function parseTypeConfigFiles($type, $files, ContainerBuilder $container)
{
$config = [];
foreach ($files as $file) {
$fileRealPath = $file->getRealPath();
if (isset($this->treatedFiles[$fileRealPath])) {
continue;
}

$typeConfig = call_user_func(self::PARSERS[$type].'::parse', $file, $container);
$container->prependExtensionConfig($this->getAlias(), $typeConfig);
$config[] = call_user_func(self::PARSERS[$type].'::parse', $file, $container);
$this->treatedFiles[$file->getRealPath()] = true;
}

return $config;
}

private function checkTypesDuplication(array $typeConfigs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ public function tearDown()
}

/**
* @expectedException \Symfony\Component\Config\Definition\Exception\ForbiddenOverwriteException
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Configs type should never contain more than one config to deal with inheritance.
*/
public function testDuplicatedType()
public function testMultipleConfigNotAllowed()
{
$type = ['foo' => []];
$configs = [$type, $type];
$configs = [['foo' => []], ['bar' => []]];
$this->extension->load($configs, $this->container);
}

Expand Down
2 changes: 0 additions & 2 deletions Tests/Functional/App/TestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Overblog\GraphQLBundle\OverblogGraphQLBundle;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\SecurityBundle\SecurityBundle;
use Symfony\Bundle\TwigBundle\TwigBundle;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand All @@ -23,7 +22,6 @@ public function registerBundles()
return [
new FrameworkBundle(),
new SecurityBundle(),
new TwigBundle(),
new OverblogGraphQLBundle(),
];
}
Expand Down
1 change: 0 additions & 1 deletion Tests/Functional/App/config/access/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
imports:
- { resource: ../config.yml }
- { resource: ../security.yml }
- { resource: ../connection/services.yml }
- { resource: ../mutation/services.yml }

Expand Down
22 changes: 20 additions & 2 deletions Tests/Functional/App/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,29 @@ framework:
secret: test
router:
resource: "%kernel.root_dir%/config/routing.yml"
templating:
engines: ['twig']
profiler:
enabled: false

security:
providers:
in_memory:
memory:
users:
ryan:
password: 123
roles: 'ROLE_USER'
admin:
password: 123
roles: 'ROLE_ADMIN'
encoders:
Symfony\Component\Security\Core\User\User: plaintext
firewalls:
graph:
pattern: ^/
http_basic: ~
stateless: true
anonymous: true

overblog_graphql:
errors_handler:
debug: false
Expand Down
1 change: 0 additions & 1 deletion Tests/Functional/App/config/public/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
imports:
- { resource: ../config.yml }
- { resource: ../security.yml }

overblog_graphql:
definitions:
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/App/config/queryComplexityEnv/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ imports:
- { resource: ../connection/services.yml }

parameters:
env(GRAPHQL_QUERY_MAX_COMPLEXITY): 10
env(GRAPHQL_QUERY_MAX_COMPLEXITY): "10"

overblog_graphql:
security:
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/App/config/queryMaxDepthEnv/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ imports:
- { resource: ../connection/services.yml }

parameters:
env(GRAPHQL_QUERY_MAX_DEPTH): 3
env(GRAPHQL_QUERY_MAX_DEPTH): "3"

overblog_graphql:
security:
Expand Down
19 changes: 0 additions & 19 deletions Tests/Functional/App/config/security.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Tests/Functional/Command/CompileCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ private function displayExpected($isVerbose = false)
\-[\-]+\s+\-[\-]+\s
class\s+path\s*
\-[\-]+\s+\-[\-]+\s
Overblog\\GraphQLBundle\\Connection\\__DEFINITIONS__\\PageInfoType {{PATH}}/PageInfoType.php
Overblog\\GraphQLBundle\\Connection\\__DEFINITIONS__\\QueryType {{PATH}}/QueryType.php
Overblog\\GraphQLBundle\\Connection\\__DEFINITIONS__\\UserType {{PATH}}/UserType.php
Overblog\\GraphQLBundle\\Connection\\__DEFINITIONS__\\friendConnectionType {{PATH}}/friendConnectionType.php
Overblog\\GraphQLBundle\\Connection\\__DEFINITIONS__\\userConnectionType {{PATH}}/userConnectionType.php
Overblog\\GraphQLBundle\\Connection\\__DEFINITIONS__\\PageInfoType {{PATH}}/PageInfoType.php
Overblog\\GraphQLBundle\\Connection\\__DEFINITIONS__\\friendEdgeType {{PATH}}/friendEdgeType.php
Overblog\\GraphQLBundle\\Connection\\__DEFINITIONS__\\userEdgeType {{PATH}}/userEdgeType.php
\-[\-]+\s+\-[\-]+\s
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"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"
},
Expand Down
6 changes: 4 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
</filter>

<php>
<ini name="error_reporting" value="E_ALL"/>
<ini name="error_reporting" value="-1"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak" />
</php>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>
</phpunit>