mirror of
https://github.com/retailcrm/graphql-php.git
synced 2025-02-06 07:49:24 +03:00
commit
86503e2e35
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,6 @@
|
|||||||
|
.phpcs-cache
|
||||||
composer.phar
|
composer.phar
|
||||||
composer.lock
|
composer.lock
|
||||||
phpcs.xml
|
phpcs.xml
|
||||||
|
phpstan.neon
|
||||||
vendor/
|
vendor/
|
||||||
|
18
.travis.yml
18
.travis.yml
@ -6,10 +6,6 @@ php:
|
|||||||
- 7.2
|
- 7.2
|
||||||
- nightly
|
- nightly
|
||||||
|
|
||||||
matrix:
|
|
||||||
allow_failures:
|
|
||||||
- php: nightly
|
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- $HOME/.composer/cache
|
- $HOME/.composer/cache
|
||||||
@ -18,10 +14,7 @@ before_install:
|
|||||||
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available"
|
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available"
|
||||||
- travis_retry composer self-update
|
- travis_retry composer self-update
|
||||||
|
|
||||||
install:
|
install: travis_retry composer update --prefer-dist
|
||||||
- composer require react/promise:2.*
|
|
||||||
- composer require psr/http-message:1.*
|
|
||||||
- travis_retry composer update --prefer-dist
|
|
||||||
|
|
||||||
script: ./vendor/bin/phpunit --group default,ReactPromise
|
script: ./vendor/bin/phpunit --group default,ReactPromise
|
||||||
|
|
||||||
@ -46,8 +39,15 @@ jobs:
|
|||||||
- wget https://scrutinizer-ci.com/ocular.phar
|
- wget https://scrutinizer-ci.com/ocular.phar
|
||||||
- php ocular.phar code-coverage:upload --format=php-clover clover.xml
|
- php ocular.phar code-coverage:upload --format=php-clover clover.xml
|
||||||
|
|
||||||
- stage: Coding standard
|
- stage: Code Quality
|
||||||
php: 7.1
|
php: 7.1
|
||||||
|
env: CODING_STANDARD
|
||||||
install: travis_retry composer install --prefer-dist
|
install: travis_retry composer install --prefer-dist
|
||||||
script:
|
script:
|
||||||
- ./vendor/bin/phpcs
|
- ./vendor/bin/phpcs
|
||||||
|
|
||||||
|
- stage: Code Quality
|
||||||
|
php: 7.1
|
||||||
|
env: STATIC_ANALYSIS
|
||||||
|
install: travis_retry composer install --prefer-dist
|
||||||
|
script: composer static-analysis
|
||||||
|
@ -15,8 +15,11 @@
|
|||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"doctrine/coding-standard": "^4.0",
|
"doctrine/coding-standard": "^4.0",
|
||||||
|
"phpstan/phpstan": "^0.10.3",
|
||||||
|
"phpstan/phpstan-phpunit": "^0.10.0",
|
||||||
"phpunit/phpunit": "^7.2",
|
"phpunit/phpunit": "^7.2",
|
||||||
"psr/http-message": "^1.0"
|
"psr/http-message": "^1.0",
|
||||||
|
"react/promise": "2.*"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"preferred-install": "dist",
|
"preferred-install": "dist",
|
||||||
@ -39,6 +42,7 @@
|
|||||||
"psr/http-message": "To use standard GraphQL server"
|
"psr/http-message": "To use standard GraphQL server"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint" : "phpcs"
|
"lint" : "phpcs",
|
||||||
|
"static-analysis": "phpstan analyse --ansi -l 1 -c phpstan.neon.dist src tests"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
phpstan.neon.dist
Normal file
3
phpstan.neon.dist
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
includes:
|
||||||
|
- vendor/phpstan/phpstan-phpunit/extension.neon
|
||||||
|
- vendor/phpstan/phpstan-phpunit/rules.neon
|
@ -6,6 +6,7 @@ namespace GraphQL\Executor\Promise;
|
|||||||
|
|
||||||
use GraphQL\Executor\Promise\Adapter\SyncPromise;
|
use GraphQL\Executor\Promise\Adapter\SyncPromise;
|
||||||
use GraphQL\Utils\Utils;
|
use GraphQL\Utils\Utils;
|
||||||
|
use React\Promise\Promise as ReactPromise;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience wrapper for promises represented by Promise Adapter
|
* Convenience wrapper for promises represented by Promise Adapter
|
||||||
|
@ -264,6 +264,7 @@ class Visitor
|
|||||||
|
|
||||||
if ($visitFn) {
|
if ($visitFn) {
|
||||||
$result = call_user_func($visitFn, $node, $key, $parent, $path, $ancestors);
|
$result = call_user_func($visitFn, $node, $key, $parent, $path, $ancestors);
|
||||||
|
$editValue = null;
|
||||||
|
|
||||||
if ($result !== null) {
|
if ($result !== null) {
|
||||||
if ($result instanceof VisitorOperation) {
|
if ($result instanceof VisitorOperation) {
|
||||||
|
@ -8,7 +8,7 @@ use GraphQL\Error\FormattedError;
|
|||||||
use GraphQL\Error\InvariantViolation;
|
use GraphQL\Error\InvariantViolation;
|
||||||
use GraphQL\Executor\ExecutionResult;
|
use GraphQL\Executor\ExecutionResult;
|
||||||
use GraphQL\Executor\Promise\Promise;
|
use GraphQL\Executor\Promise\Promise;
|
||||||
use GraphQL\Utils;
|
use GraphQL\Utils\Utils;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
use Psr\Http\Message\StreamInterface;
|
use Psr\Http\Message\StreamInterface;
|
||||||
|
@ -21,7 +21,7 @@ class InputObjectField
|
|||||||
/** @var string|null */
|
/** @var string|null */
|
||||||
public $description;
|
public $description;
|
||||||
|
|
||||||
/** @var callback|InputType */
|
/** @var callable|InputType */
|
||||||
public $type;
|
public $type;
|
||||||
|
|
||||||
/** @var InputValueDefinitionNode|null */
|
/** @var InputValueDefinitionNode|null */
|
||||||
|
@ -12,7 +12,6 @@ use function is_array;
|
|||||||
use function is_callable;
|
use function is_callable;
|
||||||
use function is_string;
|
use function is_string;
|
||||||
use function sprintf;
|
use function sprintf;
|
||||||
use function spritnf;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class InputObjectType
|
* Class InputObjectType
|
||||||
@ -70,7 +69,7 @@ class InputObjectType extends Type implements InputType, NamedType
|
|||||||
|
|
||||||
if (! is_array($fields)) {
|
if (! is_array($fields)) {
|
||||||
throw new InvariantViolation(
|
throw new InvariantViolation(
|
||||||
spritnf('%s fields must be an array or a callable which returns such an array.', $this->name)
|
sprintf('%s fields must be an array or a callable which returns such an array.', $this->name)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,9 @@ namespace GraphQL\Validator\Rules;
|
|||||||
use GraphQL\Error\Error;
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Language\AST\DirectiveNode;
|
use GraphQL\Language\AST\DirectiveNode;
|
||||||
use GraphQL\Language\AST\InputObjectTypeDefinitionNode;
|
use GraphQL\Language\AST\InputObjectTypeDefinitionNode;
|
||||||
|
use GraphQL\Language\AST\Node;
|
||||||
use GraphQL\Language\AST\NodeKind;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
|
use GraphQL\Language\AST\NodeList;
|
||||||
use GraphQL\Language\DirectiveLocation;
|
use GraphQL\Language\DirectiveLocation;
|
||||||
use GraphQL\Validator\ValidationContext;
|
use GraphQL\Validator\ValidationContext;
|
||||||
use function count;
|
use function count;
|
||||||
@ -59,7 +61,9 @@ class KnownDirectives extends ValidationRule
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param (Node|NodeList)[] $ancestors
|
* @param Node[]|NodeList[] $ancestors The type is actually (Node|NodeList)[] but this PSR-5 syntax is so far not supported by most of the tools
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function getDirectiveLocationForASTPath(array $ancestors)
|
private function getDirectiveLocationForASTPath(array $ancestors)
|
||||||
{
|
{
|
||||||
|
@ -44,10 +44,10 @@ class VariablesDefaultValueAllowed extends ValidationRule
|
|||||||
|
|
||||||
return Visitor::skipNode();
|
return Visitor::skipNode();
|
||||||
},
|
},
|
||||||
NodeKind::SELECTION_SET => function (SelectionSetNode $node) use ($context) {
|
NodeKind::SELECTION_SET => function (SelectionSetNode $node) {
|
||||||
return Visitor::skipNode();
|
return Visitor::skipNode();
|
||||||
},
|
},
|
||||||
NodeKind::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $node) use ($context) {
|
NodeKind::FRAGMENT_DEFINITION => function (FragmentDefinitionNode $node) {
|
||||||
return Visitor::skipNode();
|
return Visitor::skipNode();
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -329,7 +329,7 @@ class ExecutorTest extends TestCase
|
|||||||
'fields' => [
|
'fields' => [
|
||||||
'a' => [
|
'a' => [
|
||||||
'type' => Type::string(),
|
'type' => Type::string(),
|
||||||
'resolve' => function ($context) use ($doc, &$gotHere) {
|
'resolve' => function ($context) use (&$gotHere) {
|
||||||
$this->assertEquals('thing', $context['contextThing']);
|
$this->assertEquals('thing', $context['contextThing']);
|
||||||
$gotHere = true;
|
$gotHere = true;
|
||||||
},
|
},
|
||||||
|
@ -31,26 +31,24 @@ class ReactPromiseAdapterTest extends TestCase
|
|||||||
{
|
{
|
||||||
$reactAdapter = new ReactPromiseAdapter();
|
$reactAdapter = new ReactPromiseAdapter();
|
||||||
|
|
||||||
$this->assertSame(
|
$this->assertTrue(
|
||||||
true,
|
|
||||||
$reactAdapter->isThenable(new ReactPromise(function () {
|
$reactAdapter->isThenable(new ReactPromise(function () {
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
$this->assertSame(true, $reactAdapter->isThenable(new FulfilledPromise()));
|
$this->assertTrue($reactAdapter->isThenable(new FulfilledPromise()));
|
||||||
$this->assertSame(true, $reactAdapter->isThenable(new RejectedPromise()));
|
$this->assertTrue($reactAdapter->isThenable(new RejectedPromise()));
|
||||||
$this->assertSame(
|
$this->assertTrue(
|
||||||
true,
|
|
||||||
$reactAdapter->isThenable(new LazyPromise(function () {
|
$reactAdapter->isThenable(new LazyPromise(function () {
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
$this->assertSame(false, $reactAdapter->isThenable(false));
|
$this->assertFalse($reactAdapter->isThenable(false));
|
||||||
$this->assertSame(false, $reactAdapter->isThenable(true));
|
$this->assertFalse($reactAdapter->isThenable(true));
|
||||||
$this->assertSame(false, $reactAdapter->isThenable(1));
|
$this->assertFalse($reactAdapter->isThenable(1));
|
||||||
$this->assertSame(false, $reactAdapter->isThenable(0));
|
$this->assertFalse($reactAdapter->isThenable(0));
|
||||||
$this->assertSame(false, $reactAdapter->isThenable('test'));
|
$this->assertFalse($reactAdapter->isThenable('test'));
|
||||||
$this->assertSame(false, $reactAdapter->isThenable(''));
|
$this->assertFalse($reactAdapter->isThenable(''));
|
||||||
$this->assertSame(false, $reactAdapter->isThenable([]));
|
$this->assertFalse($reactAdapter->isThenable([]));
|
||||||
$this->assertSame(false, $reactAdapter->isThenable(new \stdClass()));
|
$this->assertFalse($reactAdapter->isThenable(new \stdClass()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConvertsReactPromisesToGraphQlOnes() : void
|
public function testConvertsReactPromisesToGraphQlOnes() : void
|
||||||
|
@ -331,7 +331,7 @@ GRAPHQL
|
|||||||
');
|
');
|
||||||
$result = Parser::parse($source);
|
$result = Parser::parse($source);
|
||||||
|
|
||||||
$loc = function ($start, $end) use ($source) {
|
$loc = function ($start, $end) {
|
||||||
return [
|
return [
|
||||||
'start' => $start,
|
'start' => $start,
|
||||||
'end' => $end,
|
'end' => $end,
|
||||||
@ -442,7 +442,7 @@ GRAPHQL
|
|||||||
');
|
');
|
||||||
$result = Parser::parse($source);
|
$result = Parser::parse($source);
|
||||||
|
|
||||||
$loc = function ($start, $end) use ($source) {
|
$loc = function ($start, $end) {
|
||||||
return [
|
return [
|
||||||
'start' => $start,
|
'start' => $start,
|
||||||
'end' => $end,
|
'end' => $end,
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace GraphQL\Tests;
|
namespace GraphQL\Tests\Language;
|
||||||
|
|
||||||
use GraphQL\Language\AST\NameNode;
|
use GraphQL\Language\AST\NameNode;
|
||||||
use GraphQL\Language\AST\ScalarTypeDefinitionNode;
|
use GraphQL\Language\AST\ScalarTypeDefinitionNode;
|
||||||
|
@ -51,7 +51,7 @@ class SerializationTest extends TestCase
|
|||||||
|
|
||||||
$expectedVars = get_object_vars($expected);
|
$expectedVars = get_object_vars($expected);
|
||||||
$actualVars = get_object_vars($actual);
|
$actualVars = get_object_vars($actual);
|
||||||
$this->assertSame(count($expectedVars), count($actualVars), $err);
|
$this->assertCount(count($expectedVars), $actualVars, $err);
|
||||||
$this->assertEquals(array_keys($expectedVars), array_keys($actualVars), $err);
|
$this->assertEquals(array_keys($expectedVars), array_keys($actualVars), $err);
|
||||||
|
|
||||||
foreach ($expectedVars as $name => $expectedValue) {
|
foreach ($expectedVars as $name => $expectedValue) {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace GraphQL\Tests;
|
namespace GraphQL\Tests\Language;
|
||||||
|
|
||||||
use GraphQL\Language\Token;
|
use GraphQL\Language\Token;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
@ -1222,7 +1222,7 @@ class VisitorTest extends ValidatorTestCase
|
|||||||
$ast,
|
$ast,
|
||||||
Visitor::visitInParallel([
|
Visitor::visitInParallel([
|
||||||
[
|
[
|
||||||
'enter' => function ($node) use (&$visited, $ast) {
|
'enter' => function ($node) use ($ast) {
|
||||||
$this->checkVisitorFnArgs($ast, func_get_args());
|
$this->checkVisitorFnArgs($ast, func_get_args());
|
||||||
if ($node->kind === 'Field' && isset($node->name->value) && $node->name->value === 'b') {
|
if ($node->kind === 'Field' && isset($node->name->value) && $node->name->value === 'b') {
|
||||||
return Visitor::removeNode();
|
return Visitor::removeNode();
|
||||||
@ -1292,7 +1292,7 @@ class VisitorTest extends ValidatorTestCase
|
|||||||
$ast,
|
$ast,
|
||||||
Visitor::visitInParallel([
|
Visitor::visitInParallel([
|
||||||
[
|
[
|
||||||
'leave' => function ($node) use (&$visited, $ast) {
|
'leave' => function ($node) use ($ast) {
|
||||||
$this->checkVisitorFnArgs($ast, func_get_args(), true);
|
$this->checkVisitorFnArgs($ast, func_get_args(), true);
|
||||||
if ($node->kind === 'Field' && isset($node->name->value) && $node->name->value === 'b') {
|
if ($node->kind === 'Field' && isset($node->name->value) && $node->name->value === 'b') {
|
||||||
return Visitor::removeNode();
|
return Visitor::removeNode();
|
||||||
|
@ -66,7 +66,7 @@ class QueryExecutionTest extends ServerTestCase
|
|||||||
$query = '{f1';
|
$query = '{f1';
|
||||||
|
|
||||||
$result = $this->executeQuery($query);
|
$result = $this->executeQuery($query);
|
||||||
$this->assertSame(null, $result->data);
|
$this->assertNull($result->data);
|
||||||
$this->assertCount(1, $result->errors);
|
$this->assertCount(1, $result->errors);
|
||||||
$this->assertContains(
|
$this->assertContains(
|
||||||
'Syntax Error: Expected Name, found <EOF>',
|
'Syntax Error: Expected Name, found <EOF>',
|
||||||
@ -202,7 +202,7 @@ class QueryExecutionTest extends ServerTestCase
|
|||||||
$called1 = false;
|
$called1 = false;
|
||||||
$called2 = false;
|
$called2 = false;
|
||||||
|
|
||||||
$this->config->setValidationRules(function (OperationParams $params) use ($q1, $q2, &$called1, &$called2) {
|
$this->config->setValidationRules(function (OperationParams $params) use ($q1, &$called1, &$called2) {
|
||||||
if ($params->query === $q1) {
|
if ($params->query === $q1) {
|
||||||
$called1 = true;
|
$called1 = true;
|
||||||
|
|
||||||
@ -376,7 +376,7 @@ class QueryExecutionTest extends ServerTestCase
|
|||||||
'Persistent query loader must return query string or instance of GraphQL\Language\AST\DocumentNode ' .
|
'Persistent query loader must return query string or instance of GraphQL\Language\AST\DocumentNode ' .
|
||||||
'but got: {"err":"err"}'
|
'but got: {"err":"err"}'
|
||||||
);
|
);
|
||||||
$this->config->setPersistentQueryLoader(function ($queryId, OperationParams $params) use (&$called) {
|
$this->config->setPersistentQueryLoader(function () {
|
||||||
return ['err' => 'err'];
|
return ['err' => 'err'];
|
||||||
});
|
});
|
||||||
$this->executePersistedQuery('some-id');
|
$this->executePersistedQuery('some-id');
|
||||||
|
@ -17,17 +17,17 @@ class ServerConfigTest extends TestCase
|
|||||||
public function testDefaults() : void
|
public function testDefaults() : void
|
||||||
{
|
{
|
||||||
$config = ServerConfig::create();
|
$config = ServerConfig::create();
|
||||||
$this->assertEquals(null, $config->getSchema());
|
$this->assertNull($config->getSchema());
|
||||||
$this->assertEquals(null, $config->getContext());
|
$this->assertNull($config->getContext());
|
||||||
$this->assertEquals(null, $config->getRootValue());
|
$this->assertNull($config->getRootValue());
|
||||||
$this->assertEquals(null, $config->getErrorFormatter());
|
$this->assertNull($config->getErrorFormatter());
|
||||||
$this->assertEquals(null, $config->getErrorsHandler());
|
$this->assertNull($config->getErrorsHandler());
|
||||||
$this->assertEquals(null, $config->getPromiseAdapter());
|
$this->assertNull($config->getPromiseAdapter());
|
||||||
$this->assertEquals(null, $config->getValidationRules());
|
$this->assertNull($config->getValidationRules());
|
||||||
$this->assertEquals(null, $config->getFieldResolver());
|
$this->assertNull($config->getFieldResolver());
|
||||||
$this->assertEquals(null, $config->getPersistentQueryLoader());
|
$this->assertNull($config->getPersistentQueryLoader());
|
||||||
$this->assertEquals(false, $config->getDebug());
|
$this->assertFalse($config->getDebug());
|
||||||
$this->assertEquals(false, $config->getQueryBatching());
|
$this->assertFalse($config->getQueryBatching());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAllowsSettingSchema() : void
|
public function testAllowsSettingSchema() : void
|
||||||
@ -166,10 +166,10 @@ class ServerConfigTest extends TestCase
|
|||||||
$config = ServerConfig::create();
|
$config = ServerConfig::create();
|
||||||
|
|
||||||
$config->setDebug(true);
|
$config->setDebug(true);
|
||||||
$this->assertSame(true, $config->getDebug());
|
$this->assertTrue($config->getDebug());
|
||||||
|
|
||||||
$config->setDebug(false);
|
$config->setDebug(false);
|
||||||
$this->assertSame(false, $config->getDebug());
|
$this->assertFalse($config->getDebug());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAcceptsArray() : void
|
public function testAcceptsArray() : void
|
||||||
@ -204,8 +204,8 @@ class ServerConfigTest extends TestCase
|
|||||||
$this->assertSame($arr['validationRules'], $config->getValidationRules());
|
$this->assertSame($arr['validationRules'], $config->getValidationRules());
|
||||||
$this->assertSame($arr['fieldResolver'], $config->getFieldResolver());
|
$this->assertSame($arr['fieldResolver'], $config->getFieldResolver());
|
||||||
$this->assertSame($arr['persistentQueryLoader'], $config->getPersistentQueryLoader());
|
$this->assertSame($arr['persistentQueryLoader'], $config->getPersistentQueryLoader());
|
||||||
$this->assertSame(true, $config->getDebug());
|
$this->assertTrue($config->getDebug());
|
||||||
$this->assertSame(true, $config->getQueryBatching());
|
$this->assertTrue($config->getQueryBatching());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testThrowsOnInvalidArrayKey() : void
|
public function testThrowsOnInvalidArrayKey() : void
|
||||||
|
@ -132,7 +132,7 @@ class EnumTypeTest extends TestCase
|
|||||||
'type' => Type::boolean(),
|
'type' => Type::boolean(),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'resolve' => function ($value, $args) use ($Complex1, $Complex2) {
|
'resolve' => function ($value, $args) use ($Complex2) {
|
||||||
if (! empty($args['provideGoodValue'])) {
|
if (! empty($args['provideGoodValue'])) {
|
||||||
// Note: this is one of the references of the internal values which
|
// Note: this is one of the references of the internal values which
|
||||||
// ComplexEnum allows.
|
// ComplexEnum allows.
|
||||||
|
@ -287,7 +287,7 @@ class ResolutionTest extends TestCase
|
|||||||
];
|
];
|
||||||
$this->assertEquals($expectedDescriptor, $eagerTypeResolution->getDescriptor());
|
$this->assertEquals($expectedDescriptor, $eagerTypeResolution->getDescriptor());
|
||||||
|
|
||||||
$this->assertSame(null, $eagerTypeResolution->resolveType('User'));
|
$this->assertNull($eagerTypeResolution->resolveType('User'));
|
||||||
$this->assertSame([], $eagerTypeResolution->resolvePossibleTypes($this->node));
|
$this->assertSame([], $eagerTypeResolution->resolvePossibleTypes($this->node));
|
||||||
$this->assertSame([], $eagerTypeResolution->resolvePossibleTypes($this->content));
|
$this->assertSame([], $eagerTypeResolution->resolvePossibleTypes($this->content));
|
||||||
$this->assertSame([], $eagerTypeResolution->resolvePossibleTypes($this->mention));
|
$this->assertSame([], $eagerTypeResolution->resolvePossibleTypes($this->mention));
|
||||||
|
@ -186,13 +186,13 @@ class ScalarSerializationTest extends TestCase
|
|||||||
{
|
{
|
||||||
$boolType = Type::boolean();
|
$boolType = Type::boolean();
|
||||||
|
|
||||||
$this->assertSame(true, $boolType->serialize('string'));
|
$this->assertTrue($boolType->serialize('string'));
|
||||||
$this->assertSame(false, $boolType->serialize(''));
|
$this->assertFalse($boolType->serialize(''));
|
||||||
$this->assertSame(true, $boolType->serialize('1'));
|
$this->assertTrue($boolType->serialize('1'));
|
||||||
$this->assertSame(true, $boolType->serialize(1));
|
$this->assertTrue($boolType->serialize(1));
|
||||||
$this->assertSame(false, $boolType->serialize(0));
|
$this->assertFalse($boolType->serialize(0));
|
||||||
$this->assertSame(true, $boolType->serialize(true));
|
$this->assertTrue($boolType->serialize(true));
|
||||||
$this->assertSame(false, $boolType->serialize(false));
|
$this->assertFalse($boolType->serialize(false));
|
||||||
// TODO: how should it behave on '0'?
|
// TODO: how should it behave on '0'?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1974,7 +1974,7 @@ class ValidationTest extends TestCase
|
|||||||
public function testRejectsDifferentInstancesOfTheSameType() : void
|
public function testRejectsDifferentInstancesOfTheSameType() : void
|
||||||
{
|
{
|
||||||
// Invalid: always creates new instance vs returning one from registry
|
// Invalid: always creates new instance vs returning one from registry
|
||||||
$typeLoader = function ($name) use (&$typeLoader) {
|
$typeLoader = function ($name) {
|
||||||
switch ($name) {
|
switch ($name) {
|
||||||
case 'Query':
|
case 'Query':
|
||||||
return new ObjectType([
|
return new ObjectType([
|
||||||
|
@ -126,7 +126,7 @@ class AstFromValueTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testDoesNotConvertsNonNullValuestoNullValue() : void
|
public function testDoesNotConvertsNonNullValuestoNullValue() : void
|
||||||
{
|
{
|
||||||
$this->assertSame(null, AST::astFromValue(null, Type::nonNull(Type::boolean())));
|
$this->assertNull(AST::astFromValue(null, Type::nonNull(Type::boolean())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -141,10 +141,10 @@ class AstFromValueTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Note: case sensitive
|
// Note: case sensitive
|
||||||
$this->assertEquals(null, AST::astFromValue('hello', $this->myEnum()));
|
$this->assertNull(AST::astFromValue('hello', $this->myEnum()));
|
||||||
|
|
||||||
// Note: Not a valid enum value
|
// Note: Not a valid enum value
|
||||||
$this->assertEquals(null, AST::astFromValue('VALUE', $this->myEnum()));
|
$this->assertNull(AST::astFromValue('VALUE', $this->myEnum()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user