mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-25 06:16:05 +03:00
Upgrade PHPUnit
This commit is contained in:
parent
bedbd32fb7
commit
24b6b736b2
@ -14,7 +14,7 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/coding-standard": "^4.0",
|
||||
"phpunit/phpunit": "^4.8",
|
||||
"phpunit/phpunit": "^7.0",
|
||||
"psr/http-message": "^1.0"
|
||||
},
|
||||
"config": {
|
||||
|
@ -1,16 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false"
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<phpunit
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
|
||||
bootstrap="vendor/autoload.php"
|
||||
>
|
||||
<php>
|
||||
<ini name="error_reporting" value="E_ALL"/>
|
||||
</php>
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="webonyx/graphql-php Test Suite">
|
||||
<directory>./tests/</directory>
|
||||
@ -26,21 +23,6 @@
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">./src</directory>
|
||||
<exclude>
|
||||
<directory>./bin</directory>
|
||||
<directory>./docs</directory>
|
||||
<directory>./build</directory>
|
||||
<directory>./tests</directory>
|
||||
<directory>./vendor</directory>
|
||||
<directory>./examples</directory>
|
||||
<directory>./benchmarks</directory>
|
||||
<file>./src/deprecated.php</file>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
|
||||
<php>
|
||||
<ini name="error_reporting" value="E_ALL"/>
|
||||
</php>
|
||||
|
||||
</phpunit>
|
||||
|
@ -5,8 +5,9 @@ use GraphQL\Error\Error;
|
||||
use GraphQL\Language\Parser;
|
||||
use GraphQL\Language\Source;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ErrorTest extends \PHPUnit_Framework_TestCase
|
||||
class ErrorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @it uses the stack of an original error
|
||||
|
@ -5,8 +5,9 @@ use GraphQL\Error\Error;
|
||||
use GraphQL\Error\FormattedError;
|
||||
use GraphQL\Language\Parser;
|
||||
use GraphQL\Language\Source;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PrintErrorTest extends \PHPUnit_Framework_TestCase
|
||||
class PrintErrorTest extends TestCase
|
||||
{
|
||||
// Describe printError
|
||||
|
||||
|
@ -12,8 +12,9 @@ use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Type\Definition\UnionType;
|
||||
|
||||
require_once __DIR__ . '/TestClasses.php';
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AbstractPromiseTest extends \PHPUnit_Framework_TestCase
|
||||
class AbstractPromiseTest extends TestCase
|
||||
{
|
||||
// DESCRIBE: Execute: Handles execution of abstract types with promises
|
||||
|
||||
|
@ -12,8 +12,9 @@ use GraphQL\Type\Definition\InterfaceType;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Type\Definition\UnionType;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AbstractTest extends \PHPUnit_Framework_TestCase
|
||||
class AbstractTest extends TestCase
|
||||
{
|
||||
// Execute: Handles execution of abstract types
|
||||
|
||||
|
@ -10,8 +10,9 @@ use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\ResolveInfo;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Utils\Utils;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DeferredFieldsTest extends \PHPUnit_Framework_TestCase
|
||||
class DeferredFieldsTest extends TestCase
|
||||
{
|
||||
private $userType;
|
||||
|
||||
|
@ -6,8 +6,9 @@ use GraphQL\Language\Parser;
|
||||
use GraphQL\Type\Schema;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DirectivesTest extends \PHPUnit_Framework_TestCase
|
||||
class DirectivesTest extends TestCase
|
||||
{
|
||||
// Describe: Execute: handles directives
|
||||
|
||||
|
@ -2,8 +2,9 @@
|
||||
namespace GraphQL\Tests\Executor;
|
||||
|
||||
use GraphQL\Executor\ExecutionResult;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ExecutionResultTest extends \PHPUnit_Framework_TestCase
|
||||
class ExecutionResultTest extends TestCase
|
||||
{
|
||||
public function testToArrayWithoutExtensions()
|
||||
{
|
||||
|
@ -14,8 +14,10 @@ use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Type\Definition\UnionType;
|
||||
use GraphQL\Type\Schema;
|
||||
use PHPUnit\Framework\Error\Error;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ExecutorLazySchemaTest extends \PHPUnit_Framework_TestCase
|
||||
class ExecutorLazySchemaTest extends TestCase
|
||||
{
|
||||
public $SomeScalarType;
|
||||
|
||||
@ -129,7 +131,7 @@ class ExecutorLazySchemaTest extends \PHPUnit_Framework_TestCase
|
||||
Warning::enable(Warning::WARNING_FULL_SCHEMA_SCAN);
|
||||
$result = Executor::execute($schema, Parser::parse($query));
|
||||
$this->assertEquals(1, count($result->errors));
|
||||
$this->assertInstanceOf('PHPUnit_Framework_Error_Warning', $result->errors[0]->getPrevious());
|
||||
$this->assertInstanceOf(Error::class, $result->errors[0]->getPrevious());
|
||||
|
||||
$this->assertEquals(
|
||||
'GraphQL Interface Type `Pet` returned `null` from it`s `resolveType` function for value: instance of '.
|
||||
|
@ -6,8 +6,9 @@ use GraphQL\Language\Parser;
|
||||
use GraphQL\Type\Schema;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ExecutorSchemaTest extends \PHPUnit_Framework_TestCase
|
||||
class ExecutorSchemaTest extends TestCase
|
||||
{
|
||||
// Execute: Handles execution with a complex schema
|
||||
|
||||
|
@ -14,8 +14,9 @@ use GraphQL\Type\Definition\InterfaceType;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\ResolveInfo;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ExecutorTest extends \PHPUnit_Framework_TestCase
|
||||
class ExecutorTest extends TestCase
|
||||
{
|
||||
public function tearDown()
|
||||
{
|
||||
|
@ -12,8 +12,9 @@ use GraphQL\Type\Schema;
|
||||
use GraphQL\Type\Definition\InterfaceType;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class LazyInterfaceTest extends \PHPUnit_Framework_TestCase
|
||||
class LazyInterfaceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Schema
|
||||
|
@ -11,8 +11,9 @@ use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Type\Schema;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ListsTest extends \PHPUnit_Framework_TestCase
|
||||
class ListsTest extends TestCase
|
||||
{
|
||||
// Describe: Execute: Handles list nullability
|
||||
|
||||
|
@ -10,8 +10,9 @@ use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Type\Schema;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class MutationsTest extends \PHPUnit_Framework_TestCase
|
||||
class MutationsTest extends TestCase
|
||||
{
|
||||
// Execute: Handles mutation execution ordering
|
||||
|
||||
|
@ -11,8 +11,9 @@ use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Type\Schema;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class NonNullTest extends \PHPUnit_Framework_TestCase
|
||||
class NonNullTest extends TestCase
|
||||
{
|
||||
/** @var \Exception */
|
||||
public $syncError;
|
||||
|
@ -6,6 +6,7 @@ namespace GraphQL\Tests\Executor\Promise;
|
||||
|
||||
use GraphQL\Executor\Promise\Adapter\ReactPromiseAdapter;
|
||||
use GraphQL\Executor\Promise\Promise;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use React\Promise\Deferred;
|
||||
use React\Promise\FulfilledPromise;
|
||||
use React\Promise\LazyPromise;
|
||||
@ -15,7 +16,7 @@ use React\Promise\RejectedPromise;
|
||||
/**
|
||||
* @group ReactPromise
|
||||
*/
|
||||
class ReactPromiseAdapterTest extends \PHPUnit_Framework_TestCase
|
||||
class ReactPromiseAdapterTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
|
@ -6,8 +6,9 @@ use GraphQL\Error\InvariantViolation;
|
||||
use GraphQL\Executor\Promise\Adapter\SyncPromise;
|
||||
use GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter;
|
||||
use GraphQL\Executor\Promise\Promise;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SyncPromiseAdapterTest extends \PHPUnit_Framework_TestCase
|
||||
class SyncPromiseAdapterTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var SyncPromiseAdapter
|
||||
@ -40,7 +41,8 @@ class SyncPromiseAdapterTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertInstanceOf('GraphQL\Executor\Promise\Promise', $result);
|
||||
$this->assertInstanceOf('GraphQL\Executor\Promise\Adapter\SyncPromise', $result->adoptedPromise);
|
||||
|
||||
$this->setExpectedException(InvariantViolation::class, 'Expected instance of GraphQL\Deferred, got (empty string)');
|
||||
$this->expectException(InvariantViolation::class);
|
||||
$this->expectExceptionMessage('Expected instance of GraphQL\Deferred, got (empty string)');
|
||||
$this->promises->convertThenable('');
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,10 @@
|
||||
namespace GraphQL\Tests\Executor\Promise;
|
||||
|
||||
use GraphQL\Executor\Promise\Adapter\SyncPromise;
|
||||
use PHPUnit\Framework\Error\Error;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SyncPromiseTest extends \PHPUnit_Framework_TestCase
|
||||
class SyncPromiseTest extends TestCase
|
||||
{
|
||||
public function getFulfilledPromiseResolveData()
|
||||
{
|
||||
@ -47,7 +49,8 @@ class SyncPromiseTest extends \PHPUnit_Framework_TestCase
|
||||
$promise->resolve($resolvedValue);
|
||||
$this->assertEquals(SyncPromise::FULFILLED, $promise->state);
|
||||
|
||||
$this->setExpectedException(\Exception::class, 'Cannot change value of fulfilled promise');
|
||||
$this->expectException(\Throwable::class);
|
||||
$this->expectExceptionMessage('Cannot change value of fulfilled promise');
|
||||
$promise->resolve($resolvedValue . '-other-value');
|
||||
}
|
||||
|
||||
@ -68,7 +71,8 @@ class SyncPromiseTest extends \PHPUnit_Framework_TestCase
|
||||
$promise->resolve($resolvedValue);
|
||||
$this->assertEquals(SyncPromise::FULFILLED, $promise->state);
|
||||
|
||||
$this->setExpectedException(\Exception::class, 'Cannot reject fulfilled promise');
|
||||
$this->expectException(\Throwable::class);
|
||||
$this->expectExceptionMessage('Cannot reject fulfilled promise');
|
||||
$promise->reject(new \Exception('anything'));
|
||||
}
|
||||
|
||||
@ -162,7 +166,8 @@ class SyncPromiseTest extends \PHPUnit_Framework_TestCase
|
||||
$promise->reject($rejectedReason);
|
||||
$this->assertEquals(SyncPromise::REJECTED, $promise->state);
|
||||
|
||||
$this->setExpectedException(\Exception::class, 'Cannot change rejection reason');
|
||||
$this->expectException(\Throwable::class);
|
||||
$this->expectExceptionMessage('Cannot change rejection reason');
|
||||
$promise->reject(new \Exception('other-reason'));
|
||||
|
||||
}
|
||||
@ -184,7 +189,8 @@ class SyncPromiseTest extends \PHPUnit_Framework_TestCase
|
||||
$promise->reject($rejectedReason);
|
||||
$this->assertEquals(SyncPromise::REJECTED, $promise->state);
|
||||
|
||||
$this->setExpectedException(\Exception::class, 'Cannot resolve rejected promise');
|
||||
$this->expectException(\Throwable::class);
|
||||
$this->expectExceptionMessage('Cannot resolve rejected promise');
|
||||
$promise->resolve('anything');
|
||||
}
|
||||
|
||||
@ -289,7 +295,7 @@ class SyncPromiseTest extends \PHPUnit_Framework_TestCase
|
||||
try {
|
||||
$promise->reject('a');
|
||||
$this->fail('Expected exception not thrown');
|
||||
} catch (\PHPUnit_Framework_AssertionFailedError $e) {
|
||||
} catch (Error $e) {
|
||||
throw $e;
|
||||
} catch (\Throwable $e) {
|
||||
$this->assertEquals(SyncPromise::PENDING, $promise->state);
|
||||
|
@ -7,8 +7,9 @@ use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
|
||||
require_once __DIR__ . '/TestClasses.php';
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ResolveTest extends \PHPUnit_Framework_TestCase
|
||||
class ResolveTest extends TestCase
|
||||
{
|
||||
// Execute: resolve function
|
||||
|
||||
|
@ -13,8 +13,9 @@ use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\ResolveInfo;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Type\Definition\UnionType;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class UnionInterfaceTest extends \PHPUnit_Framework_TestCase
|
||||
class UnionInterfaceTest extends TestCase
|
||||
{
|
||||
public $schema;
|
||||
public $garfield;
|
||||
|
@ -9,9 +9,10 @@ use GraphQL\Language\AST\VariableNode;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Type\Schema;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ValuesTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
class ValuesTest extends TestCase
|
||||
{
|
||||
public function testGetIDVariableValues()
|
||||
{
|
||||
$this->expectInputVariablesMatchOutputVariables(['idInput' => '123456789']);
|
||||
|
@ -10,8 +10,9 @@ use GraphQL\Type\Schema;
|
||||
use GraphQL\Type\Definition\InputObjectType;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class VariablesTest extends \PHPUnit_Framework_TestCase
|
||||
class VariablesTest extends TestCase
|
||||
{
|
||||
// Execute: Handles inputs
|
||||
// Handles objects and nullability
|
||||
@ -510,10 +511,8 @@ class VariablesTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testSerializingAnArrayViaGraphQLStringThrowsTypeError()
|
||||
{
|
||||
$this->setExpectedException(
|
||||
Error::class,
|
||||
'String cannot represent non scalar value: [1,2,3]'
|
||||
);
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('String cannot represent non scalar value: [1,2,3]');
|
||||
Type::string()->serialize([1, 2, 3]);
|
||||
}
|
||||
|
||||
|
@ -7,8 +7,9 @@ use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Language\Token;
|
||||
use GraphQL\Error\SyntaxError;
|
||||
use GraphQL\Utils\Utils;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class LexerTest extends \PHPUnit_Framework_TestCase
|
||||
class LexerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @it disallows uncommon control characters
|
||||
@ -545,7 +546,8 @@ class LexerTest extends \PHPUnit_Framework_TestCase
|
||||
$lexer = new Lexer(new Source($q));
|
||||
$this->assertArraySubset(['kind' => Token::NAME, 'start' => 0, 'end' => 1, 'value' => 'a'], (array) $lexer->advance());
|
||||
|
||||
$this->setExpectedException(SyntaxError::class, 'Syntax Error: Invalid number, expected digit but got: "b"');
|
||||
$this->expectException(SyntaxError::class);
|
||||
$this->expectExceptionMessage('Syntax Error: Invalid number, expected digit but got: "b"');
|
||||
try {
|
||||
$lexer->advance();
|
||||
$this->fail('Expected exception not thrown');
|
||||
@ -614,7 +616,8 @@ class LexerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
private function expectSyntaxError($text, $message, $location)
|
||||
{
|
||||
$this->setExpectedException(SyntaxError::class, $message);
|
||||
$this->expectException(SyntaxError::class);
|
||||
$this->expectExceptionMessage($message);
|
||||
try {
|
||||
$this->lexOne($text);
|
||||
} catch (SyntaxError $error) {
|
||||
|
@ -15,24 +15,28 @@ use GraphQL\Language\Source;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Error\SyntaxError;
|
||||
use GraphQL\Utils\Utils;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ParserTest extends \PHPUnit_Framework_TestCase
|
||||
class ParserTest extends TestCase
|
||||
{
|
||||
public function testAssertsThatASourceToParseIsNotNull()
|
||||
{
|
||||
$this->setExpectedException(InvariantViolation::class, 'GraphQL query body is expected to be string, but got NULL');
|
||||
$this->expectException(InvariantViolation::class);
|
||||
$this->expectExceptionMessage('GraphQL query body is expected to be string, but got NULL');
|
||||
Parser::parse(null);
|
||||
}
|
||||
|
||||
public function testAssertsThatASourceToParseIsNotArray()
|
||||
{
|
||||
$this->setExpectedException(InvariantViolation::class, 'GraphQL query body is expected to be string, but got array');
|
||||
$this->expectException(InvariantViolation::class);
|
||||
$this->expectExceptionMessage('GraphQL query body is expected to be string, but got array');
|
||||
Parser::parse(['a' => 'b']);
|
||||
}
|
||||
|
||||
public function testAssertsThatASourceToParseIsNotObject()
|
||||
{
|
||||
$this->setExpectedException(InvariantViolation::class, 'GraphQL query body is expected to be string, but got stdClass');
|
||||
$this->expectException(InvariantViolation::class);
|
||||
$this->expectExceptionMessage('GraphQL query body is expected to be string, but got stdClass');
|
||||
Parser::parse(new \stdClass());
|
||||
}
|
||||
|
||||
@ -462,7 +466,7 @@ fragment $fragmentName on Type {
|
||||
// not throw
|
||||
Parser::parse($source, ['experimentalFragmentVariables' => true]);
|
||||
|
||||
$this->setExpectedException(SyntaxError::class);
|
||||
$this->expectException(SyntaxError::class);
|
||||
Parser::parse($source);
|
||||
}
|
||||
|
||||
@ -648,7 +652,8 @@ fragment $fragmentName on Type {
|
||||
|
||||
private function expectSyntaxError($text, $message, $location)
|
||||
{
|
||||
$this->setExpectedException(SyntaxError::class, $message);
|
||||
$this->expectException(SyntaxError::class);
|
||||
$this->expectExceptionMessage($message);
|
||||
try {
|
||||
Parser::parse($text);
|
||||
} catch (SyntaxError $error) {
|
||||
|
@ -12,8 +12,9 @@ use GraphQL\Language\AST\VariableNode;
|
||||
use GraphQL\Language\AST\VariableDefinitionNode;
|
||||
use GraphQL\Language\Parser;
|
||||
use GraphQL\Language\Printer;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PrinterTest extends \PHPUnit_Framework_TestCase
|
||||
class PrinterTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @it does not alter ast
|
||||
@ -45,7 +46,8 @@ class PrinterTest extends \PHPUnit_Framework_TestCase
|
||||
public function testProducesHelpfulErrorMessages()
|
||||
{
|
||||
$badAst1 = new \ArrayObject(['random' => 'Data']);
|
||||
$this->setExpectedException(\Exception::class, 'Invalid AST Node: {"random":"Data"}');
|
||||
$this->expectException(\Throwable::class);
|
||||
$this->expectExceptionMessage('Invalid AST Node: {"random":"Data"}');
|
||||
Printer::doPrint($badAst1);
|
||||
}
|
||||
|
||||
|
@ -5,8 +5,9 @@ use GraphQL\Error\SyntaxError;
|
||||
use GraphQL\Language\AST\NodeKind;
|
||||
use GraphQL\Language\Parser;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SchemaParserTest extends \PHPUnit_Framework_TestCase
|
||||
class SchemaParserTest extends TestCase
|
||||
{
|
||||
// Describe: Schema Parser
|
||||
|
||||
@ -927,7 +928,8 @@ input Hello {
|
||||
|
||||
private function expectSyntaxError($text, $message, $location)
|
||||
{
|
||||
$this->setExpectedException(SyntaxError::class, $message);
|
||||
$this->expectException(SyntaxError::class);
|
||||
$this->expectExceptionMessage($message);
|
||||
try {
|
||||
Parser::parse($text);
|
||||
} catch (SyntaxError $error) {
|
||||
|
@ -5,8 +5,10 @@ use GraphQL\Language\AST\NameNode;
|
||||
use GraphQL\Language\AST\ScalarTypeDefinitionNode;
|
||||
use GraphQL\Language\Parser;
|
||||
use GraphQL\Language\Printer;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Throwable;
|
||||
|
||||
class SchemaPrinterTest extends \PHPUnit_Framework_TestCase
|
||||
class SchemaPrinterTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @it prints minimal ast
|
||||
@ -24,9 +26,11 @@ class SchemaPrinterTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testProducesHelpfulErrorMessages()
|
||||
{
|
||||
$this->expectException(Throwable::class);
|
||||
$this->expectExceptionMessage('Invalid AST Node: {"random":"Data"}');
|
||||
|
||||
// $badAst1 = { random: 'Data' };
|
||||
$badAst = (object) ['random' => 'Data'];
|
||||
$this->setExpectedException('Exception', 'Invalid AST Node: {"random":"Data"}');
|
||||
Printer::doPrint($badAst);
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,9 @@ use GraphQL\Language\AST\Node;
|
||||
use GraphQL\Language\AST\NodeList;
|
||||
use GraphQL\Language\Parser;
|
||||
use GraphQL\Utils\AST;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SerializationTest extends \PHPUnit_Framework_TestCase
|
||||
class SerializationTest extends TestCase
|
||||
{
|
||||
public function testSerializesAst()
|
||||
{
|
||||
|
@ -2,8 +2,9 @@
|
||||
namespace GraphQL\Tests;
|
||||
|
||||
use GraphQL\Language\Token;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class TokenTest extends \PHPUnit_Framework_TestCase
|
||||
class TokenTest extends TestCase
|
||||
{
|
||||
public function testReturnTokenOnArray()
|
||||
{
|
||||
|
@ -12,11 +12,11 @@ use GraphQL\Language\AST\SelectionSetNode;
|
||||
use GraphQL\Language\Parser;
|
||||
use GraphQL\Language\Printer;
|
||||
use GraphQL\Language\Visitor;
|
||||
use GraphQL\Tests\Validator\TestCase;
|
||||
use GraphQL\Tests\Validator\ValidatorTestCase;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Utils\TypeInfo;
|
||||
|
||||
class VisitorTest extends \PHPUnit_Framework_TestCase
|
||||
class VisitorTest extends ValidatorTestCase
|
||||
{
|
||||
private function getNodeByPath(DocumentNode $ast, $path)
|
||||
{
|
||||
@ -1318,7 +1318,7 @@ class VisitorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$visited = [];
|
||||
|
||||
$typeInfo = new TypeInfo(TestCase::getTestSchema());
|
||||
$typeInfo = new TypeInfo(ValidatorTestCase::getTestSchema());
|
||||
|
||||
$ast = Parser::parse('{ human(id: 4) { name, pets { ... { name } }, unknown } }');
|
||||
Visitor::visit($ast, Visitor::visitWithTypeInfo($typeInfo, [
|
||||
@ -1402,7 +1402,7 @@ class VisitorTest extends \PHPUnit_Framework_TestCase
|
||||
public function testMaintainsTypeInfoDuringEdit()
|
||||
{
|
||||
$visited = [];
|
||||
$typeInfo = new TypeInfo(TestCase::getTestSchema());
|
||||
$typeInfo = new TypeInfo(ValidatorTestCase::getTestSchema());
|
||||
|
||||
$ast = Parser::parse(
|
||||
'{ human(id: 4) { name, pets }, alien }'
|
||||
|
@ -5,8 +5,9 @@ use GraphQL\Executor\ExecutionResult;
|
||||
use GraphQL\Server\Helper;
|
||||
use GraphQL\Tests\Server\Psr7\PsrStreamStub;
|
||||
use GraphQL\Tests\Server\Psr7\PsrResponseStub;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PsrResponseTest extends \PHPUnit_Framework_TestCase
|
||||
class PsrResponseTest extends TestCase
|
||||
{
|
||||
public function testConvertsResultToPsrResponse()
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ use GraphQL\Validator\DocumentValidator;
|
||||
use GraphQL\Validator\Rules\CustomValidationRule;
|
||||
use GraphQL\Validator\ValidationContext;
|
||||
|
||||
class QueryExecutionTest extends TestCase
|
||||
class QueryExecutionTest extends ServerTestCase
|
||||
{
|
||||
/**
|
||||
* @var ServerConfig
|
||||
@ -319,8 +319,8 @@ class QueryExecutionTest extends TestCase
|
||||
|
||||
public function testProhibitsInvalidPersistedQueryLoader()
|
||||
{
|
||||
$this->setExpectedException(
|
||||
InvariantViolation::class,
|
||||
$this->expectException(InvariantViolation::class);
|
||||
$this->expectExceptionMessage(
|
||||
'Persistent query loader must return query string or instance of GraphQL\Language\AST\DocumentNode ' .
|
||||
'but got: {"err":"err"}'
|
||||
);
|
||||
@ -388,10 +388,8 @@ class QueryExecutionTest extends TestCase
|
||||
|
||||
public function testProhibitsUnexpectedValidationRules()
|
||||
{
|
||||
$this->setExpectedException(
|
||||
InvariantViolation::class,
|
||||
'Expecting validation rules to be array or callable returning array, but got: instance of stdClass'
|
||||
);
|
||||
$this->expectException(InvariantViolation::class);
|
||||
$this->expectExceptionMessage('Expecting validation rules to be array or callable returning array, but got: instance of stdClass');
|
||||
$this->config->setValidationRules(function(OperationParams $params) {
|
||||
return new \stdClass();
|
||||
});
|
||||
|
@ -8,8 +8,9 @@ use GraphQL\Server\OperationParams;
|
||||
use GraphQL\Server\RequestError;
|
||||
use GraphQL\Tests\Server\Psr7\PsrRequestStub;
|
||||
use GraphQL\Tests\Server\Psr7\PsrStreamStub;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class RequestParsingTest extends \PHPUnit_Framework_TestCase
|
||||
class RequestParsingTest extends TestCase
|
||||
{
|
||||
public function testParsesGraphqlRequest()
|
||||
{
|
||||
@ -184,7 +185,8 @@ class RequestParsingTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$body = 'not really{} a json';
|
||||
|
||||
$this->setExpectedException(RequestError::class, 'Could not parse JSON: Syntax error');
|
||||
$this->expectException(RequestError::class);
|
||||
$this->expectExceptionMessage('Could not parse JSON: Syntax error');
|
||||
$this->parseRawRequest('application/json', $body);
|
||||
}
|
||||
|
||||
@ -192,7 +194,8 @@ class RequestParsingTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$body = 'not really{} a json';
|
||||
|
||||
$this->setExpectedException(InvariantViolation::class, 'PSR-7 request is expected to provide parsed body for "application/json" requests but got null');
|
||||
$this->expectException(InvariantViolation::class);
|
||||
$this->expectExceptionMessage('PSR-7 request is expected to provide parsed body for "application/json" requests but got null');
|
||||
$this->parsePsrRequest('application/json', $body);
|
||||
}
|
||||
|
||||
@ -216,7 +219,8 @@ class RequestParsingTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$body = '"str"';
|
||||
|
||||
$this->setExpectedException(RequestError::class, 'GraphQL Server expects JSON object or array, but got "str"');
|
||||
$this->expectException(RequestError::class);
|
||||
$this->expectExceptionMessage('GraphQL Server expects JSON object or array, but got "str"');
|
||||
$this->parseRawRequest('application/json', $body);
|
||||
}
|
||||
|
||||
@ -224,7 +228,8 @@ class RequestParsingTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$body = '"str"';
|
||||
|
||||
$this->setExpectedException(RequestError::class, 'GraphQL Server expects JSON object or array, but got "str"');
|
||||
$this->expectException(RequestError::class);
|
||||
$this->expectExceptionMessage('GraphQL Server expects JSON object or array, but got "str"');
|
||||
$this->parsePsrRequest('application/json', $body);
|
||||
}
|
||||
|
||||
@ -233,7 +238,8 @@ class RequestParsingTest extends \PHPUnit_Framework_TestCase
|
||||
$contentType = 'not-supported-content-type';
|
||||
$body = 'test';
|
||||
|
||||
$this->setExpectedException(RequestError::class, 'Unexpected content type: "not-supported-content-type"');
|
||||
$this->expectException(RequestError::class);
|
||||
$this->expectExceptionMessage('Unexpected content type: "not-supported-content-type"');
|
||||
$this->parseRawRequest($contentType, $body);
|
||||
}
|
||||
|
||||
@ -242,31 +248,36 @@ class RequestParsingTest extends \PHPUnit_Framework_TestCase
|
||||
$contentType = 'not-supported-content-type';
|
||||
$body = 'test';
|
||||
|
||||
$this->setExpectedException(RequestError::class, 'Unexpected content type: "not-supported-content-type"');
|
||||
$this->expectException(RequestError::class);
|
||||
$this->expectExceptionMessage('Unexpected content type: "not-supported-content-type"');
|
||||
$this->parseRawRequest($contentType, $body);
|
||||
}
|
||||
|
||||
public function testFailsWithMissingContentTypeRaw()
|
||||
{
|
||||
$this->setExpectedException(RequestError::class, 'Missing "Content-Type" header');
|
||||
$this->expectException(RequestError::class);
|
||||
$this->expectExceptionMessage('Missing "Content-Type" header');
|
||||
$this->parseRawRequest(null, 'test');
|
||||
}
|
||||
|
||||
public function testFailsWithMissingContentTypePsr()
|
||||
{
|
||||
$this->setExpectedException(RequestError::class, 'Missing "Content-Type" header');
|
||||
$this->expectException(RequestError::class);
|
||||
$this->expectExceptionMessage('Missing "Content-Type" header');
|
||||
$this->parsePsrRequest(null, 'test');
|
||||
}
|
||||
|
||||
public function testFailsOnMethodsOtherThanPostOrGetRaw()
|
||||
{
|
||||
$this->setExpectedException(RequestError::class, 'HTTP Method "PUT" is not supported');
|
||||
$this->expectException(RequestError::class);
|
||||
$this->expectExceptionMessage('HTTP Method "PUT" is not supported');
|
||||
$this->parseRawRequest('application/json', json_encode([]), "PUT");
|
||||
}
|
||||
|
||||
public function testFailsOnMethodsOtherThanPostOrGetPsr()
|
||||
{
|
||||
$this->setExpectedException(RequestError::class, 'HTTP Method "PUT" is not supported');
|
||||
$this->expectException(RequestError::class);
|
||||
$this->expectExceptionMessage('HTTP Method "PUT" is not supported');
|
||||
$this->parsePsrRequest('application/json', json_encode([]), "PUT");
|
||||
}
|
||||
|
||||
|
@ -3,8 +3,9 @@ namespace GraphQL\Tests\Server;
|
||||
|
||||
use GraphQL\Server\Helper;
|
||||
use GraphQL\Server\OperationParams;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class RequestValidationTest extends \PHPUnit_Framework_TestCase
|
||||
class RequestValidationTest extends TestCase
|
||||
{
|
||||
public function testSimpleRequestShouldValidate()
|
||||
{
|
||||
|
@ -7,8 +7,9 @@ use GraphQL\Type\Schema;
|
||||
use GraphQL\Server\ServerConfig;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ServerConfigTest extends \PHPUnit_Framework_TestCase
|
||||
class ServerConfigTest extends TestCase
|
||||
{
|
||||
public function testDefaults()
|
||||
{
|
||||
@ -195,10 +196,8 @@ class ServerConfigTest extends \PHPUnit_Framework_TestCase
|
||||
'missingKey' => 'value'
|
||||
];
|
||||
|
||||
$this->setExpectedException(
|
||||
InvariantViolation::class,
|
||||
'Unknown server config option "missingKey"'
|
||||
);
|
||||
$this->expectException(InvariantViolation::class);
|
||||
$this->expectExceptionMessage('Unknown server config option "missingKey"');
|
||||
|
||||
ServerConfig::create($arr);
|
||||
}
|
||||
@ -208,10 +207,8 @@ class ServerConfigTest extends \PHPUnit_Framework_TestCase
|
||||
$rules = new \stdClass();
|
||||
$config = ServerConfig::create();
|
||||
|
||||
$this->setExpectedException(
|
||||
InvariantViolation::class,
|
||||
'Server config expects array of validation rules or callable returning such array, but got instance of stdClass'
|
||||
);
|
||||
$this->expectException(InvariantViolation::class);
|
||||
$this->expectExceptionMessage('Server config expects array of validation rules or callable returning such array, but got instance of stdClass');
|
||||
|
||||
$config->setValidationRules($rules);
|
||||
}
|
||||
|
@ -7,8 +7,9 @@ use GraphQL\Error\UserError;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Type\Schema;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
abstract class TestCase extends \PHPUnit_Framework_TestCase
|
||||
abstract class ServerTestCase extends TestCase
|
||||
{
|
||||
protected function buildSchema()
|
||||
{
|
@ -8,7 +8,7 @@ use GraphQL\Server\StandardServer;
|
||||
use GraphQL\Tests\Server\Psr7\PsrRequestStub;
|
||||
use GraphQL\Tests\Server\Psr7\PsrStreamStub;
|
||||
|
||||
class StandardServerTest extends TestCase
|
||||
class StandardServerTest extends ServerTestCase
|
||||
{
|
||||
/**
|
||||
* @var ServerConfig
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
namespace GraphQL\Tests;
|
||||
|
||||
|
||||
use GraphQL\GraphQL;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class StarWarsIntrospectionTest extends \PHPUnit_Framework_TestCase
|
||||
class StarWarsIntrospectionTest extends TestCase
|
||||
{
|
||||
// Star Wars Introspection Tests
|
||||
// Basic Introspection
|
||||
|
@ -3,8 +3,9 @@ namespace GraphQL\Tests;
|
||||
|
||||
|
||||
use GraphQL\GraphQL;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class StarWarsQueryTest extends \PHPUnit_Framework_TestCase
|
||||
class StarWarsQueryTest extends TestCase
|
||||
{
|
||||
// Star Wars Query Tests
|
||||
// Basic Queries
|
||||
|
@ -3,8 +3,9 @@ namespace GraphQL\Tests;
|
||||
|
||||
use GraphQL\Language\Parser;
|
||||
use GraphQL\Validator\DocumentValidator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class StartWarsValidationTest extends \PHPUnit_Framework_TestCase
|
||||
class StarWarsValidationTest extends TestCase
|
||||
{
|
||||
// Star Wars Validation Tests
|
||||
// Basic Queries
|
||||
|
@ -14,8 +14,9 @@ use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Type\Definition\UnionType;
|
||||
use GraphQL\Utils\Utils;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class DefinitionTest extends \PHPUnit_Framework_TestCase
|
||||
class DefinitionTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var ObjectType
|
||||
|
@ -8,8 +8,9 @@ use GraphQL\Type\Definition\EnumType;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Type\Introspection;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class EnumTypeTest extends \PHPUnit_Framework_TestCase
|
||||
class EnumTypeTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Schema
|
||||
|
@ -11,8 +11,9 @@ use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Type\Introspection;
|
||||
use GraphQL\Validator\Rules\ProvidedNonNullArguments;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class IntrospectionTest extends \PHPUnit_Framework_TestCase
|
||||
class IntrospectionTest extends TestCase
|
||||
{
|
||||
// Describe: Introspection
|
||||
|
||||
|
@ -9,8 +9,9 @@ use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Type\Definition\UnionType;
|
||||
use GraphQL\Type\EagerResolution;
|
||||
use GraphQL\Type\LazyResolution;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ResolutionTest extends \PHPUnit_Framework_TestCase
|
||||
class ResolutionTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var ObjectType
|
||||
@ -563,7 +564,8 @@ class ResolutionTest extends \PHPUnit_Framework_TestCase
|
||||
public function testLazyThrowsOnInvalidLoadedType()
|
||||
{
|
||||
$lazy = $this->createLazy();
|
||||
$this->setExpectedException(InvariantViolation::class, "Lazy Type Resolution Error: Expecting GraphQL Type instance, but got integer");
|
||||
$this->expectException(InvariantViolation::class);
|
||||
$this->expectExceptionMessage('Lazy Type Resolution Error: Expecting GraphQL Type instance, but got integer');
|
||||
$lazy->resolveType('int');
|
||||
}
|
||||
|
||||
@ -571,7 +573,8 @@ class ResolutionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$tmp = new InterfaceType(['name' => 'a', 'fields' => []]);
|
||||
$lazy = $this->createLazy();
|
||||
$this->setExpectedException(InvariantViolation::class, 'Lazy Type Resolution Error: Implementation null of interface a is expected to be instance of ObjectType, but got NULL');
|
||||
$this->expectException(InvariantViolation::class);
|
||||
$this->expectExceptionMessage('Lazy Type Resolution Error: Implementation null of interface a is expected to be instance of ObjectType, but got NULL');
|
||||
$lazy->resolvePossibleTypes($tmp);
|
||||
}
|
||||
|
||||
@ -579,7 +582,8 @@ class ResolutionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$tmp = new InterfaceType(['name' => 'b', 'fields' => []]);
|
||||
$lazy = $this->createLazy();
|
||||
$this->setExpectedException(InvariantViolation::class, 'Lazy Type Resolution Error: Expecting GraphQL Type instance, but got integer');
|
||||
$this->expectException(InvariantViolation::class);
|
||||
$this->expectExceptionMessage('Lazy Type Resolution Error: Expecting GraphQL Type instance, but got integer');
|
||||
$lazy->resolvePossibleTypes($tmp);
|
||||
}
|
||||
}
|
||||
|
@ -6,8 +6,9 @@ use GraphQL\Type\Schema;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\ResolveInfo;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ResolveInfoTest extends \PHPUnit_Framework_TestCase
|
||||
class ResolveInfoTest extends TestCase
|
||||
{
|
||||
public function testFieldSelection()
|
||||
{
|
||||
|
@ -3,8 +3,9 @@ namespace GraphQL\Tests\Type;
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ScalarSerializationTest extends \PHPUnit_Framework_TestCase
|
||||
class ScalarSerializationTest extends TestCase
|
||||
{
|
||||
// Type System: Scalar coercion
|
||||
|
||||
@ -30,14 +31,16 @@ class ScalarSerializationTest extends \PHPUnit_Framework_TestCase
|
||||
// The GraphQL specification does not allow serializing non-integer values
|
||||
// as Int to avoid accidental data loss.
|
||||
$intType = Type::int();
|
||||
$this->setExpectedException(Error::class, 'Int cannot represent non-integer value: 0.1');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Int cannot represent non-integer value: 0.1');
|
||||
$intType->serialize(0.1);
|
||||
}
|
||||
|
||||
public function testSerializesOutputIntCannotRepresentFloat2()
|
||||
{
|
||||
$intType = Type::int();
|
||||
$this->setExpectedException(Error::class, 'Int cannot represent non-integer value: 1.1');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Int cannot represent non-integer value: 1.1');
|
||||
$intType->serialize(1.1);
|
||||
|
||||
}
|
||||
@ -45,7 +48,8 @@ class ScalarSerializationTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSerializesOutputIntCannotRepresentNegativeFloat()
|
||||
{
|
||||
$intType = Type::int();
|
||||
$this->setExpectedException(Error::class, 'Int cannot represent non-integer value: -1.1');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Int cannot represent non-integer value: -1.1');
|
||||
$intType->serialize(-1.1);
|
||||
|
||||
}
|
||||
@ -53,7 +57,8 @@ class ScalarSerializationTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSerializesOutputIntCannotRepresentNumericString()
|
||||
{
|
||||
$intType = Type::int();
|
||||
$this->setExpectedException(Error::class, '');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Int cannot represent non 32-bit signed integer value: Int cannot represent non-integer value: "-1.1"');
|
||||
$intType->serialize('Int cannot represent non-integer value: "-1.1"');
|
||||
|
||||
}
|
||||
@ -63,7 +68,8 @@ class ScalarSerializationTest extends \PHPUnit_Framework_TestCase
|
||||
// Maybe a safe PHP int, but bigger than 2^32, so not
|
||||
// representable as a GraphQL Int
|
||||
$intType = Type::int();
|
||||
$this->setExpectedException(Error::class, 'Int cannot represent non 32-bit signed integer value: 9876504321');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Int cannot represent non 32-bit signed integer value: 9876504321');
|
||||
$intType->serialize(9876504321);
|
||||
|
||||
}
|
||||
@ -71,28 +77,32 @@ class ScalarSerializationTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSerializesOutputIntCannotRepresentLowerThan32Bits()
|
||||
{
|
||||
$intType = Type::int();
|
||||
$this->setExpectedException(Error::class, 'Int cannot represent non 32-bit signed integer value: -9876504321');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Int cannot represent non 32-bit signed integer value: -9876504321');
|
||||
$intType->serialize(-9876504321);
|
||||
}
|
||||
|
||||
public function testSerializesOutputIntCannotRepresentBiggerThanSigned32Bits()
|
||||
{
|
||||
$intType = Type::int();
|
||||
$this->setExpectedException(Error::class, 'Int cannot represent non 32-bit signed integer value: 1.0E+100');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Int cannot represent non 32-bit signed integer value: 1.0E+100');
|
||||
$intType->serialize(1e100);
|
||||
}
|
||||
|
||||
public function testSerializesOutputIntCannotRepresentLowerThanSigned32Bits()
|
||||
{
|
||||
$intType = Type::int();
|
||||
$this->setExpectedException(Error::class, 'Int cannot represent non 32-bit signed integer value: -1.0E+100');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Int cannot represent non 32-bit signed integer value: -1.0E+100');
|
||||
$intType->serialize(-1e100);
|
||||
}
|
||||
|
||||
public function testSerializesOutputIntCannotRepresentString()
|
||||
{
|
||||
$intType = Type::int();
|
||||
$this->setExpectedException(Error::class, 'Int cannot represent non 32-bit signed integer value: one');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Int cannot represent non 32-bit signed integer value: one');
|
||||
$intType->serialize('one');
|
||||
|
||||
}
|
||||
@ -100,7 +110,8 @@ class ScalarSerializationTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSerializesOutputIntCannotRepresentEmptyString()
|
||||
{
|
||||
$intType = Type::int();
|
||||
$this->setExpectedException(Error::class, 'Int cannot represent non 32-bit signed integer value: (empty string)');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Int cannot represent non 32-bit signed integer value: (empty string)');
|
||||
$intType->serialize('');
|
||||
}
|
||||
|
||||
@ -126,14 +137,16 @@ class ScalarSerializationTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSerializesOutputFloatCannotRepresentString()
|
||||
{
|
||||
$floatType = Type::float();
|
||||
$this->setExpectedException(Error::class, 'Float cannot represent non numeric value: one');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Float cannot represent non numeric value: one');
|
||||
$floatType->serialize('one');
|
||||
}
|
||||
|
||||
public function testSerializesOutputFloatCannotRepresentEmptyString()
|
||||
{
|
||||
$floatType = Type::float();
|
||||
$this->setExpectedException(Error::class, 'Float cannot represent non numeric value: (empty string)');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Float cannot represent non numeric value: (empty string)');
|
||||
$floatType->serialize('');
|
||||
}
|
||||
|
||||
@ -156,14 +169,16 @@ class ScalarSerializationTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSerializesOutputStringsCannotRepresentArray()
|
||||
{
|
||||
$stringType = Type::string();
|
||||
$this->setExpectedException(Error::class, 'String cannot represent non scalar value: []');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('String cannot represent non scalar value: []');
|
||||
$stringType->serialize([]);
|
||||
}
|
||||
|
||||
public function testSerializesOutputStringsCannotRepresentObject()
|
||||
{
|
||||
$stringType = Type::string();
|
||||
$this->setExpectedException(Error::class, 'String cannot represent non scalar value: instance of stdClass');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('String cannot represent non scalar value: instance of stdClass');
|
||||
$stringType->serialize(new \stdClass());
|
||||
}
|
||||
|
||||
@ -202,7 +217,8 @@ class ScalarSerializationTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSerializesOutputIDCannotRepresentObject()
|
||||
{
|
||||
$idType = Type::id();
|
||||
$this->setExpectedException(Error::class, 'ID type cannot represent non scalar value: instance of stdClass');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('ID type cannot represent non scalar value: instance of stdClass');
|
||||
$idType->serialize(new \stdClass());
|
||||
}
|
||||
}
|
||||
|
@ -8,8 +8,9 @@ use GraphQL\Type\Definition\InterfaceType;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Type\Schema;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class TypeLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
class TypeLoaderTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var ObjectType
|
||||
@ -163,10 +164,8 @@ class TypeLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testSchemaRejectsNonCallableTypeLoader()
|
||||
{
|
||||
$this->setExpectedException(
|
||||
InvariantViolation::class,
|
||||
'Schema type loader must be callable if provided but got: []'
|
||||
);
|
||||
$this->expectException(InvariantViolation::class);
|
||||
$this->expectExceptionMessage('Schema type loader must be callable if provided but got: []');
|
||||
|
||||
new Schema([
|
||||
'query' => new ObjectType([
|
||||
@ -262,10 +261,8 @@ class TypeLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
'typeLoader' => function() {}
|
||||
]);
|
||||
|
||||
$this->setExpectedException(
|
||||
InvariantViolation::class,
|
||||
'Type loader is expected to return valid type "NonExistingType", but it returned null'
|
||||
);
|
||||
$this->expectException(InvariantViolation::class);
|
||||
$this->expectExceptionMessage('Type loader is expected to return valid type "NonExistingType", but it returned null');
|
||||
|
||||
$schema->getType('NonExistingType');
|
||||
}
|
||||
@ -279,10 +276,8 @@ class TypeLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
]);
|
||||
|
||||
$this->setExpectedException(
|
||||
InvariantViolation::class,
|
||||
'Type loader is expected to return valid type "Node", but it returned instance of stdClass'
|
||||
);
|
||||
$this->expectException(InvariantViolation::class);
|
||||
$this->expectExceptionMessage('Type loader is expected to return valid type "Node", but it returned instance of stdClass');
|
||||
|
||||
$schema->getType('Node');
|
||||
}
|
||||
@ -296,10 +291,8 @@ class TypeLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
]);
|
||||
|
||||
$this->setExpectedException(
|
||||
InvariantViolation::class,
|
||||
'Type loader is expected to return type "Node", but it returned "Content"'
|
||||
);
|
||||
$this->expectException(InvariantViolation::class);
|
||||
$this->expectExceptionMessage('Type loader is expected to return type "Node", but it returned "Content"');
|
||||
|
||||
$schema->getType('Node');
|
||||
}
|
||||
@ -313,10 +306,8 @@ class TypeLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
]);
|
||||
|
||||
$this->setExpectedException(
|
||||
\Exception::class,
|
||||
'This is the exception we are looking for'
|
||||
);
|
||||
$this->expectException(\Throwable::class);
|
||||
$this->expectExceptionMessage('This is the exception we are looking for');
|
||||
|
||||
$schema->getType('Node');
|
||||
}
|
||||
|
@ -14,8 +14,9 @@ use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Type\Definition\UnionType;
|
||||
use GraphQL\Utils\BuildSchema;
|
||||
use GraphQL\Utils\Utils;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ValidationTest extends \PHPUnit_Framework_TestCase
|
||||
class ValidationTest extends TestCase
|
||||
{
|
||||
public $SomeScalarType;
|
||||
|
||||
@ -857,10 +858,8 @@ class ValidationTest extends \PHPUnit_Framework_TestCase
|
||||
'value' => ['isDeprecated' => true]
|
||||
]
|
||||
]);
|
||||
$this->setExpectedException(
|
||||
InvariantViolation::class,
|
||||
'SomeEnum.value should provide "deprecationReason" instead of "isDeprecated".'
|
||||
);
|
||||
$this->expectException(InvariantViolation::class);
|
||||
$this->expectExceptionMessage('SomeEnum.value should provide "deprecationReason" instead of "isDeprecated".');
|
||||
$enum->assertValid();
|
||||
}
|
||||
|
||||
@ -1756,8 +1755,8 @@ class ValidationTest extends \PHPUnit_Framework_TestCase
|
||||
'query' => $typeLoader('Query'),
|
||||
'typeLoader' => $typeLoader
|
||||
]);
|
||||
$this->setExpectedException(
|
||||
InvariantViolation::class,
|
||||
$this->expectException(InvariantViolation::class);
|
||||
$this->expectExceptionMessage(
|
||||
'Type loader returns different instance for Query than field/argument definitions. '.
|
||||
'Make sure you always return the same instance for the same type name.'
|
||||
);
|
||||
|
@ -4,8 +4,9 @@ namespace GraphQL\Tests\Utils;
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Error\InvariantViolation;
|
||||
use GraphQL\Utils\Utils;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AssertValidNameTest extends \PHPUnit_Framework_TestCase
|
||||
class AssertValidNameTest extends TestCase
|
||||
{
|
||||
// Describe: assertValidName()
|
||||
|
||||
@ -14,10 +15,8 @@ class AssertValidNameTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testThrowsForUseOfLeadingDoubleUnderscores()
|
||||
{
|
||||
$this->setExpectedException(
|
||||
Error::class,
|
||||
'"__bad" must not begin with "__", which is reserved by GraphQL introspection.'
|
||||
);
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('"__bad" must not begin with "__", which is reserved by GraphQL introspection.');
|
||||
Utils::assertValidName('__bad');
|
||||
}
|
||||
|
||||
@ -26,10 +25,8 @@ class AssertValidNameTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testThrowsForNonStrings()
|
||||
{
|
||||
$this->setExpectedException(
|
||||
InvariantViolation::class,
|
||||
'Expected string'
|
||||
);
|
||||
$this->expectException(InvariantViolation::class);
|
||||
$this->expectExceptionMessage('Expected string');
|
||||
Utils::assertValidName([]);
|
||||
}
|
||||
|
||||
@ -38,10 +35,8 @@ class AssertValidNameTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testThrowsForNamesWithInvalidCharacters()
|
||||
{
|
||||
$this->setExpectedException(
|
||||
Error::class,
|
||||
'Names must match'
|
||||
);
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Names must match');
|
||||
Utils::assertValidName('>--()-->');
|
||||
}
|
||||
}
|
||||
|
@ -15,8 +15,9 @@ use GraphQL\Type\Definition\EnumType;
|
||||
use GraphQL\Type\Definition\InputObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Utils\AST;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ASTFromValueTest extends \PHPUnit_Framework_TestCase
|
||||
class AstFromValueTest extends TestCase
|
||||
{
|
||||
// Describe: astFromValue
|
||||
|
||||
@ -48,13 +49,15 @@ class ASTFromValueTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
// GraphQL spec does not allow coercing non-integer values to Int to avoid
|
||||
// accidental data loss.
|
||||
$this->setExpectedException(\Exception::class, 'Int cannot represent non-integer value: 123.5');
|
||||
$this->expectException(\Throwable::class);
|
||||
$this->expectExceptionMessage('Int cannot represent non-integer value: 123.5');
|
||||
AST::astFromValue(123.5, Type::int());
|
||||
}
|
||||
|
||||
public function testConvertsIntValuesToASTsCannotRepresentNon32bitsInteger()
|
||||
{
|
||||
$this->setExpectedException(\Exception::class, 'Int cannot represent non 32-bit signed integer value: 1.0E+40');
|
||||
$this->expectException(\Throwable::class);
|
||||
$this->expectExceptionMessage('Int cannot represent non 32-bit signed integer value: 1.0E+40');
|
||||
AST::astFromValue(1e40, Type::int()); // Note: js version will produce 1e+40, both values are valid GraphQL floats
|
||||
}
|
||||
|
||||
|
@ -3,8 +3,9 @@ namespace GraphQL\Tests\Utils;
|
||||
|
||||
use GraphQL\Language\Parser;
|
||||
use GraphQL\Utils\AST;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ASTFromValueUntypedTest extends \PHPUnit_Framework_TestCase
|
||||
class AstFromValueUntypedTest extends TestCase
|
||||
{
|
||||
// Describe: valueFromASTUntyped
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Tests\Utils;
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\GraphQL;
|
||||
use GraphQL\Language\AST\EnumTypeDefinitionNode;
|
||||
use GraphQL\Language\AST\InterfaceTypeDefinitionNode;
|
||||
@ -12,8 +13,9 @@ use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Utils\BuildSchema;
|
||||
use GraphQL\Utils\SchemaPrinter;
|
||||
use GraphQL\Type\Definition\Directive;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BuildSchemaTest extends \PHPUnit_Framework_TestCase
|
||||
class BuildSchemaTest extends TestCase
|
||||
{
|
||||
// Describe: Schema Builder
|
||||
|
||||
@ -868,7 +870,8 @@ type Query {
|
||||
*/
|
||||
public function testAllowsOnlySingleSchemaDefinition()
|
||||
{
|
||||
$this->setExpectedException('GraphQL\Error\Error', 'Must provide only one schema definition.');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Must provide only one schema definition.');
|
||||
$body = '
|
||||
schema {
|
||||
query: Hello
|
||||
@ -891,7 +894,8 @@ type Hello {
|
||||
*/
|
||||
public function testAllowsOnlySingleQueryType()
|
||||
{
|
||||
$this->setExpectedException('GraphQL\Error\Error', 'Must provide only one query type in schema.');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Must provide only one query type in schema.');
|
||||
$body = '
|
||||
schema {
|
||||
query: Hello
|
||||
@ -915,7 +919,8 @@ type Yellow {
|
||||
*/
|
||||
public function testAllowsOnlySingleMutationType()
|
||||
{
|
||||
$this->setExpectedException('GraphQL\Error\Error', 'Must provide only one mutation type in schema.');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Must provide only one mutation type in schema.');
|
||||
$body = '
|
||||
schema {
|
||||
query: Hello
|
||||
@ -940,7 +945,8 @@ type Yellow {
|
||||
*/
|
||||
public function testAllowsOnlySingleSubscriptionType()
|
||||
{
|
||||
$this->setExpectedException('GraphQL\Error\Error', 'Must provide only one subscription type in schema.');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Must provide only one subscription type in schema.');
|
||||
$body = '
|
||||
schema {
|
||||
query: Hello
|
||||
@ -965,7 +971,8 @@ type Yellow {
|
||||
*/
|
||||
public function testUnknownTypeReferenced()
|
||||
{
|
||||
$this->setExpectedException('GraphQL\Error\Error', 'Type "Bar" not found in document.');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Type "Bar" not found in document.');
|
||||
$body = '
|
||||
schema {
|
||||
query: Hello
|
||||
@ -985,7 +992,8 @@ type Hello {
|
||||
*/
|
||||
public function testUnknownTypeInInterfaceList()
|
||||
{
|
||||
$this->setExpectedException('GraphQL\Error\Error', 'Type "Bar" not found in document.');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Type "Bar" not found in document.');
|
||||
$body = '
|
||||
schema {
|
||||
query: Hello
|
||||
@ -1005,7 +1013,8 @@ type Hello implements Bar {
|
||||
*/
|
||||
public function testUnknownTypeInUnionList()
|
||||
{
|
||||
$this->setExpectedException('GraphQL\Error\Error', 'Type "Bar" not found in document.');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Type "Bar" not found in document.');
|
||||
$body = '
|
||||
schema {
|
||||
query: Hello
|
||||
@ -1024,7 +1033,8 @@ type Hello { testUnion: TestUnion }
|
||||
*/
|
||||
public function testUnknownQueryType()
|
||||
{
|
||||
$this->setExpectedException('GraphQL\Error\Error', 'Specified query type "Wat" not found in document.');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Specified query type "Wat" not found in document.');
|
||||
$body = '
|
||||
schema {
|
||||
query: Wat
|
||||
@ -1043,7 +1053,8 @@ type Hello {
|
||||
*/
|
||||
public function testUnknownMutationType()
|
||||
{
|
||||
$this->setExpectedException('GraphQL\Error\Error', 'Specified mutation type "Wat" not found in document.');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Specified mutation type "Wat" not found in document.');
|
||||
$body = '
|
||||
schema {
|
||||
query: Hello
|
||||
@ -1063,7 +1074,8 @@ type Hello {
|
||||
*/
|
||||
public function testUnknownSubscriptionType()
|
||||
{
|
||||
$this->setExpectedException('GraphQL\Error\Error', 'Specified subscription type "Awesome" not found in document.');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Specified subscription type "Awesome" not found in document.');
|
||||
$body = '
|
||||
schema {
|
||||
query: Hello
|
||||
@ -1088,7 +1100,8 @@ type Wat {
|
||||
*/
|
||||
public function testDoesNotConsiderOperationNames()
|
||||
{
|
||||
$this->setExpectedException('GraphQL\Error\Error', 'Specified query type "Foo" not found in document.');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Specified query type "Foo" not found in document.');
|
||||
$body = '
|
||||
schema {
|
||||
query: Foo
|
||||
@ -1105,7 +1118,8 @@ query Foo { field }
|
||||
*/
|
||||
public function testDoesNotConsiderFragmentNames()
|
||||
{
|
||||
$this->setExpectedException('GraphQL\Error\Error', 'Specified query type "Foo" not found in document.');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Specified query type "Foo" not found in document.');
|
||||
$body = '
|
||||
schema {
|
||||
query: Foo
|
||||
@ -1137,7 +1151,8 @@ type Repeated {
|
||||
';
|
||||
$doc = Parser::parse($body);
|
||||
|
||||
$this->setExpectedException('GraphQL\Error\Error', 'Type "Repeated" was defined more than once.');
|
||||
$this->expectException(Error::class);
|
||||
$this->expectExceptionMessage('Type "Repeated" was defined more than once.');
|
||||
BuildSchema::buildAST($doc);
|
||||
}
|
||||
|
||||
|
@ -8,8 +8,9 @@ use GraphQL\Type\Definition\InputObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Utils\Utils;
|
||||
use GraphQL\Utils\Value;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CoerceValueTest extends \PHPUnit_Framework_TestCase
|
||||
class CoerceValueTest extends TestCase
|
||||
{
|
||||
private $testEnum;
|
||||
private $testInputObject;
|
||||
|
@ -1,14 +1,16 @@
|
||||
<?php
|
||||
namespace Utils;
|
||||
|
||||
use GraphQL\Error\InvariantViolation;
|
||||
use GraphQL\Type\Definition\InputObjectType;
|
||||
use GraphQL\Type\Definition\InterfaceType;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Type\Definition\UnionType;
|
||||
use GraphQL\Utils\TypeInfo;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ExtractTypesTest extends \PHPUnit_Framework_TestCase
|
||||
class ExtractTypesTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var ObjectType
|
||||
@ -326,10 +328,8 @@ class ExtractTypesTest extends \PHPUnit_Framework_TestCase
|
||||
]
|
||||
]);
|
||||
|
||||
$this->setExpectedException(
|
||||
'\GraphQL\Error\InvariantViolation',
|
||||
"Schema must contain unique named types but contains multiple types named \"User\""
|
||||
);
|
||||
$this->expectException(InvariantViolation::class);
|
||||
$this->expectExceptionMessage('Schema must contain unique named types but contains multiple types named "User"');
|
||||
TypeInfo::extractTypes($queryType);
|
||||
}
|
||||
}
|
||||
|
@ -12,8 +12,9 @@ use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Type\Definition\UnionType;
|
||||
use GraphQL\Type\Schema;
|
||||
use GraphQL\Utils\FindBreakingChanges;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FindBreakingChangesTest extends \PHPUnit_Framework_TestCase
|
||||
class FindBreakingChangesTest extends TestCase
|
||||
{
|
||||
private $queryType;
|
||||
|
||||
|
@ -6,8 +6,9 @@ use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Utils\Utils;
|
||||
use GraphQL\Validator\DocumentValidator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class IsValidLiteralValueTest extends \PHPUnit_Framework_TestCase
|
||||
class IsValidLiteralValueTest extends TestCase
|
||||
{
|
||||
// DESCRIBE: isValidLiteralValue
|
||||
|
||||
|
@ -4,8 +4,9 @@ namespace GraphQL\Tests\Utils;
|
||||
|
||||
use GraphQL\Utils\Utils;
|
||||
use GraphQL\Utils\MixedStore;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class MixedStoreTest extends \PHPUnit_Framework_TestCase
|
||||
class MixedStoreTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var MixedStore
|
||||
|
@ -5,8 +5,9 @@ use GraphQL\Executor\Values;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Utils\Utils;
|
||||
use GraphQL\Utils\Value;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class QuotedOrListTest extends \PHPUnit_Framework_TestCase
|
||||
class QuotedOrListTest extends TestCase
|
||||
{
|
||||
// DESCRIBE: quotedOrList
|
||||
|
||||
@ -15,7 +16,7 @@ class QuotedOrListTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testResturnsResultsWhenInputIsEmpty()
|
||||
{
|
||||
$this->setExpectedException(\LogicException::class);
|
||||
$this->expectException(\LogicException::class);
|
||||
Utils::quotedOrList([]);
|
||||
}
|
||||
|
||||
|
@ -13,8 +13,9 @@ use GraphQL\Type\Definition\EnumType;
|
||||
use GraphQL\Type\Definition\UnionType;
|
||||
use GraphQL\Utils\BuildSchema;
|
||||
use GraphQL\Utils\SchemaPrinter;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SchemaPrinterTest extends \PHPUnit_Framework_TestCase
|
||||
class SchemaPrinterTest extends TestCase
|
||||
{
|
||||
// Describe: Type System Printer
|
||||
|
||||
|
@ -5,8 +5,9 @@ use GraphQL\Executor\Values;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Utils\Utils;
|
||||
use GraphQL\Utils\Value;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SuggestionListTest extends \PHPUnit_Framework_TestCase
|
||||
class SuggestionListTest extends TestCase
|
||||
{
|
||||
// DESCRIBE: suggestionList
|
||||
|
||||
|
@ -8,8 +8,9 @@ use GraphQL\Type\Definition\InputObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Utils\Utils;
|
||||
use GraphQL\Utils\AST;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ValueFromAstTest extends \PHPUnit_Framework_TestCase
|
||||
class ValueFromAstTest extends TestCase
|
||||
{
|
||||
private function runTestCase($type, $valueText, $expected)
|
||||
{
|
||||
|
@ -2,15 +2,17 @@
|
||||
namespace GraphQL\Tests;
|
||||
|
||||
use GraphQL\Utils\Utils;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class UtilsTest extends \PHPUnit_Framework_TestCase
|
||||
class UtilsTest extends TestCase
|
||||
{
|
||||
public function testAssignThrowsExceptionOnMissingRequiredKey()
|
||||
{
|
||||
$object = new \stdClass();
|
||||
$object->requiredKey = 'value';
|
||||
|
||||
$this->setExpectedException(\InvalidArgumentException::class, 'Key requiredKey is expected to be set and not to be null');
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Key requiredKey is expected to be set and not to be null');
|
||||
Utils::assign($object, [], ['requiredKey']);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use GraphQL\Error\FormattedError;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Validator\Rules\DisableIntrospection;
|
||||
|
||||
class DisableIntrospectionTest extends TestCase
|
||||
class DisableIntrospectionTest extends ValidatorTestCase
|
||||
{
|
||||
// Validate: Disable Introspection
|
||||
|
||||
|
@ -6,7 +6,7 @@ use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Validator\Rules\ExecutableDefinitions;
|
||||
use GraphQL\Validator\Rules\KnownDirectives;
|
||||
|
||||
class ExecutableDefinitionsTest extends TestCase
|
||||
class ExecutableDefinitionsTest extends ValidatorTestCase
|
||||
{
|
||||
// Validate: Executable definitions
|
||||
|
||||
|
@ -5,7 +5,7 @@ use GraphQL\Error\FormattedError;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Validator\Rules\FieldsOnCorrectType;
|
||||
|
||||
class FieldsOnCorrectTypeTest extends TestCase
|
||||
class FieldsOnCorrectTypeTest extends ValidatorTestCase
|
||||
{
|
||||
// Validate: Fields on correct type
|
||||
|
||||
|
@ -5,7 +5,7 @@ use GraphQL\Error\FormattedError;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Validator\Rules\FragmentsOnCompositeTypes;
|
||||
|
||||
class FragmentsOnCompositeTypesTest extends TestCase
|
||||
class FragmentsOnCompositeTypesTest extends ValidatorTestCase
|
||||
{
|
||||
// Validate: Fragments on composite types
|
||||
|
||||
|
@ -5,7 +5,7 @@ use GraphQL\Error\FormattedError;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Validator\Rules\KnownArgumentNames;
|
||||
|
||||
class KnownArgumentNamesTest extends TestCase
|
||||
class KnownArgumentNamesTest extends ValidatorTestCase
|
||||
{
|
||||
// Validate: Known argument names:
|
||||
|
||||
|
@ -5,7 +5,7 @@ use GraphQL\Error\FormattedError;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Validator\Rules\KnownDirectives;
|
||||
|
||||
class KnownDirectivesTest extends TestCase
|
||||
class KnownDirectivesTest extends ValidatorTestCase
|
||||
{
|
||||
// Validate: Known directives
|
||||
|
||||
|
@ -5,7 +5,7 @@ use GraphQL\Validator\Rules\KnownFragmentNames;
|
||||
use GraphQL\Error\FormattedError;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
|
||||
class KnownFragmentNamesTest extends TestCase
|
||||
class KnownFragmentNamesTest extends ValidatorTestCase
|
||||
{
|
||||
// Validate: Known fragment names
|
||||
|
||||
|
@ -5,7 +5,7 @@ use GraphQL\Error\FormattedError;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Validator\Rules\KnownTypeNames;
|
||||
|
||||
class KnownTypeNamesTest extends TestCase
|
||||
class KnownTypeNamesTest extends ValidatorTestCase
|
||||
{
|
||||
// Validate: Known type names
|
||||
|
||||
|
@ -5,7 +5,7 @@ use GraphQL\Error\FormattedError;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Validator\Rules\LoneAnonymousOperation;
|
||||
|
||||
class LoneAnonymousOperationTest extends TestCase
|
||||
class LoneAnonymousOperationTest extends ValidatorTestCase
|
||||
{
|
||||
// Validate: Anonymous operation must be alone
|
||||
|
||||
|
@ -5,7 +5,7 @@ use GraphQL\Error\FormattedError;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Validator\Rules\NoFragmentCycles;
|
||||
|
||||
class NoFragmentCyclesTest extends TestCase
|
||||
class NoFragmentCyclesTest extends ValidatorTestCase
|
||||
{
|
||||
// Validate: No circular fragment spreads
|
||||
|
||||
|
@ -5,7 +5,7 @@ use GraphQL\Error\FormattedError;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Validator\Rules\NoUndefinedVariables;
|
||||
|
||||
class NoUndefinedVariablesTest extends TestCase
|
||||
class NoUndefinedVariablesTest extends ValidatorTestCase
|
||||
{
|
||||
// Validate: No undefined variables
|
||||
|
||||
|
@ -5,7 +5,7 @@ use GraphQL\Error\FormattedError;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Validator\Rules\NoUnusedFragments;
|
||||
|
||||
class NoUnusedFragmentsTest extends TestCase
|
||||
class NoUnusedFragmentsTest extends ValidatorTestCase
|
||||
{
|
||||
// Validate: No unused fragments
|
||||
|
||||
|
@ -5,7 +5,7 @@ use GraphQL\Error\FormattedError;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Validator\Rules\NoUnusedVariables;
|
||||
|
||||
class NoUnusedVariablesTest extends TestCase
|
||||
class NoUnusedVariablesTest extends ValidatorTestCase
|
||||
{
|
||||
// Validate: No unused variables
|
||||
|
||||
|
@ -9,7 +9,7 @@ use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Validator\Rules\OverlappingFieldsCanBeMerged;
|
||||
|
||||
class OverlappingFieldsCanBeMergedTest extends TestCase
|
||||
class OverlappingFieldsCanBeMergedTest extends ValidatorTestCase
|
||||
{
|
||||
// Validate: Overlapping fields can be merged
|
||||
|
||||
|
@ -5,7 +5,7 @@ use GraphQL\Error\FormattedError;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Validator\Rules\PossibleFragmentSpreads;
|
||||
|
||||
class PossibleFragmentSpreadsTest extends TestCase
|
||||
class PossibleFragmentSpreadsTest extends ValidatorTestCase
|
||||
{
|
||||
// Validate: Possible fragment spreads
|
||||
|
||||
|
@ -5,7 +5,7 @@ use GraphQL\Error\FormattedError;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Validator\Rules\ProvidedNonNullArguments;
|
||||
|
||||
class ProvidedNonNullArgumentsTest extends TestCase
|
||||
class ProvidedNonNullArgumentsTest extends ValidatorTestCase
|
||||
{
|
||||
// Validate: Provided required arguments
|
||||
|
||||
|
@ -9,7 +9,7 @@ use GraphQL\Validator\Rules\CustomValidationRule;
|
||||
use GraphQL\Validator\Rules\QueryComplexity;
|
||||
use GraphQL\Validator\ValidationContext;
|
||||
|
||||
class QueryComplexityTest extends AbstractQuerySecurityTest
|
||||
class QueryComplexityTest extends QuerySecurityTestCase
|
||||
{
|
||||
/** @var QueryComplexity */
|
||||
private static $rule;
|
||||
@ -179,7 +179,7 @@ class QueryComplexityTest extends AbstractQuerySecurityTest
|
||||
$this->assertEquals(1, count($errors));
|
||||
$this->assertSame($reportedError, $errors[0]);
|
||||
|
||||
$this->setExpectedException('GraphQL\Error\Error');
|
||||
$this->expectException(Error::class);
|
||||
DocumentValidator::validate(
|
||||
QuerySecuritySchema::buildSchema(),
|
||||
Parser::parse($query),
|
||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Tests\Validator;
|
||||
|
||||
use GraphQL\Validator\Rules\QueryDepth;
|
||||
|
||||
class QueryDepthTest extends AbstractQuerySecurityTest
|
||||
class QueryDepthTest extends QuerySecurityTestCase
|
||||
{
|
||||
/**
|
||||
* @param $max
|
||||
|
@ -6,8 +6,9 @@ use GraphQL\Language\Parser;
|
||||
use GraphQL\Type\Introspection;
|
||||
use GraphQL\Validator\DocumentValidator;
|
||||
use GraphQL\Validator\Rules\AbstractQuerySecurity;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
abstract class AbstractQuerySecurityTest extends \PHPUnit_Framework_TestCase
|
||||
abstract class QuerySecurityTestCase extends TestCase
|
||||
{
|
||||
/**
|
||||
* @param $max
|
@ -5,7 +5,7 @@ use GraphQL\Error\FormattedError;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Validator\Rules\ScalarLeafs;
|
||||
|
||||
class ScalarLeafsTest extends TestCase
|
||||
class ScalarLeafsTest extends ValidatorTestCase
|
||||
{
|
||||
// Validate: Scalar leafs
|
||||
|
||||
|
@ -5,7 +5,7 @@ use GraphQL\Error\FormattedError;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Validator\Rules\UniqueArgumentNames;
|
||||
|
||||
class UniqueArgumentNamesTest extends TestCase
|
||||
class UniqueArgumentNamesTest extends ValidatorTestCase
|
||||
{
|
||||
// Validate: Unique argument names
|
||||
|
||||
|
@ -3,7 +3,7 @@ namespace GraphQL\Tests\Validator;
|
||||
|
||||
use GraphQL\Validator\Rules\UniqueDirectivesPerLocation;
|
||||
|
||||
class UniqueDirectivesPerLocationTest extends TestCase
|
||||
class UniqueDirectivesPerLocationTest extends ValidatorTestCase
|
||||
{
|
||||
/**
|
||||
* @it no directives
|
||||
|
@ -5,7 +5,7 @@ use GraphQL\Error\FormattedError;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Validator\Rules\UniqueFragmentNames;
|
||||
|
||||
class UniqueFragmentNamesTest extends TestCase
|
||||
class UniqueFragmentNamesTest extends ValidatorTestCase
|
||||
{
|
||||
// Validate: Unique fragment names
|
||||
|
||||
|
@ -5,7 +5,7 @@ use GraphQL\Error\FormattedError;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Validator\Rules\UniqueInputFieldNames;
|
||||
|
||||
class UniqueInputFieldNamesTest extends TestCase
|
||||
class UniqueInputFieldNamesTest extends ValidatorTestCase
|
||||
{
|
||||
// Validate: Unique input field names
|
||||
|
||||
|
@ -5,7 +5,7 @@ use GraphQL\Error\FormattedError;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Validator\Rules\UniqueOperationNames;
|
||||
|
||||
class UniqueOperationNamesTest extends TestCase
|
||||
class UniqueOperationNamesTest extends ValidatorTestCase
|
||||
{
|
||||
// Validate: Unique operation names
|
||||
|
||||
|
@ -5,7 +5,7 @@ use GraphQL\Error\FormattedError;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Validator\Rules\UniqueVariableNames;
|
||||
|
||||
class UniqueVariableNamesTest extends TestCase
|
||||
class UniqueVariableNamesTest extends ValidatorTestCase
|
||||
{
|
||||
// Validate: Unique variable names
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace GraphQL\Tests\Validator;
|
||||
|
||||
class ValidationTest extends TestCase
|
||||
class ValidationTest extends ValidatorTestCase
|
||||
{
|
||||
// Validate: Supports full validation
|
||||
|
||||
|
@ -12,8 +12,9 @@ use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Type\Definition\UnionType;
|
||||
use GraphQL\Validator\DocumentValidator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
abstract class TestCase extends \PHPUnit_Framework_TestCase
|
||||
abstract class ValidatorTestCase extends TestCase
|
||||
{
|
||||
/**
|
||||
* @return Schema
|
@ -5,7 +5,7 @@ use GraphQL\Error\FormattedError;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Validator\Rules\ValuesOfCorrectType;
|
||||
|
||||
class ValuesOfCorrectTypeTest extends TestCase
|
||||
class ValuesOfCorrectTypeTest extends ValidatorTestCase
|
||||
{
|
||||
private function badValue($typeName, $value, $line, $column, $message = null)
|
||||
{
|
||||
|
@ -5,7 +5,7 @@ use GraphQL\Error\FormattedError;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Validator\Rules\VariablesAreInputTypes;
|
||||
|
||||
class VariablesAreInputTypesTest extends TestCase
|
||||
class VariablesAreInputTypesTest extends ValidatorTestCase
|
||||
{
|
||||
// Validate: Variables are input types
|
||||
|
||||
|
@ -5,7 +5,7 @@ use GraphQL\Error\FormattedError;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Validator\Rules\VariablesDefaultValueAllowed;
|
||||
|
||||
class VariablesDefaultValueAllowedTest extends TestCase
|
||||
class VariablesDefaultValueAllowedTest extends ValidatorTestCase
|
||||
{
|
||||
private function defaultForRequiredVar($varName, $typeName, $guessTypeName, $line, $column)
|
||||
{
|
||||
|
@ -5,7 +5,7 @@ use GraphQL\Error\FormattedError;
|
||||
use GraphQL\Language\SourceLocation;
|
||||
use GraphQL\Validator\Rules\VariablesInAllowedPosition;
|
||||
|
||||
class VariablesInAllowedPositionTest extends TestCase
|
||||
class VariablesInAllowedPositionTest extends ValidatorTestCase
|
||||
{
|
||||
// Validate: Variables are in allowed positions
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user