diff --git a/composer.json b/composer.json index dc8e02f..9b45e15 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 9927677..197feb9 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,16 +1,13 @@ - + + + + + - ./tests/ @@ -26,21 +23,6 @@ ./src - - ./bin - ./docs - ./build - ./tests - ./vendor - ./examples - ./benchmarks - ./src/deprecated.php - - - - - - diff --git a/tests/Error/ErrorTest.php b/tests/Error/ErrorTest.php index 3843835..8c98e7b 100644 --- a/tests/Error/ErrorTest.php +++ b/tests/Error/ErrorTest.php @@ -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 diff --git a/tests/Error/PrintErrorTest.php b/tests/Error/PrintErrorTest.php index aa4affc..acb2428 100644 --- a/tests/Error/PrintErrorTest.php +++ b/tests/Error/PrintErrorTest.php @@ -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 diff --git a/tests/Executor/AbstractPromiseTest.php b/tests/Executor/AbstractPromiseTest.php index 70d245d..59c8957 100644 --- a/tests/Executor/AbstractPromiseTest.php +++ b/tests/Executor/AbstractPromiseTest.php @@ -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 diff --git a/tests/Executor/AbstractTest.php b/tests/Executor/AbstractTest.php index 4d89c8c..057b6a3 100644 --- a/tests/Executor/AbstractTest.php +++ b/tests/Executor/AbstractTest.php @@ -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 diff --git a/tests/Executor/DeferredFieldsTest.php b/tests/Executor/DeferredFieldsTest.php index 45219d1..083d24c 100644 --- a/tests/Executor/DeferredFieldsTest.php +++ b/tests/Executor/DeferredFieldsTest.php @@ -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; diff --git a/tests/Executor/DirectivesTest.php b/tests/Executor/DirectivesTest.php index ed8fbd0..811f63f 100644 --- a/tests/Executor/DirectivesTest.php +++ b/tests/Executor/DirectivesTest.php @@ -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 diff --git a/tests/Executor/ExecutionResultTest.php b/tests/Executor/ExecutionResultTest.php index 68bff90..deab57a 100644 --- a/tests/Executor/ExecutionResultTest.php +++ b/tests/Executor/ExecutionResultTest.php @@ -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() { diff --git a/tests/Executor/ExecutorLazySchemaTest.php b/tests/Executor/ExecutorLazySchemaTest.php index 8fd7772..a62091c 100644 --- a/tests/Executor/ExecutorLazySchemaTest.php +++ b/tests/Executor/ExecutorLazySchemaTest.php @@ -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 '. diff --git a/tests/Executor/ExecutorSchemaTest.php b/tests/Executor/ExecutorSchemaTest.php index d79cc71..a192bf6 100644 --- a/tests/Executor/ExecutorSchemaTest.php +++ b/tests/Executor/ExecutorSchemaTest.php @@ -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 diff --git a/tests/Executor/ExecutorTest.php b/tests/Executor/ExecutorTest.php index bbc0813..845f98e 100644 --- a/tests/Executor/ExecutorTest.php +++ b/tests/Executor/ExecutorTest.php @@ -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() { diff --git a/tests/Executor/LazyInterfaceTest.php b/tests/Executor/LazyInterfaceTest.php index 5085c57..73af88e 100644 --- a/tests/Executor/LazyInterfaceTest.php +++ b/tests/Executor/LazyInterfaceTest.php @@ -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 diff --git a/tests/Executor/ListsTest.php b/tests/Executor/ListsTest.php index 15a8dd2..f691a20 100644 --- a/tests/Executor/ListsTest.php +++ b/tests/Executor/ListsTest.php @@ -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 diff --git a/tests/Executor/MutationsTest.php b/tests/Executor/MutationsTest.php index a1c790a..369fc73 100644 --- a/tests/Executor/MutationsTest.php +++ b/tests/Executor/MutationsTest.php @@ -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 diff --git a/tests/Executor/NonNullTest.php b/tests/Executor/NonNullTest.php index bb18ac2..7792d61 100644 --- a/tests/Executor/NonNullTest.php +++ b/tests/Executor/NonNullTest.php @@ -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; diff --git a/tests/Executor/Promise/ReactPromiseAdapterTest.php b/tests/Executor/Promise/ReactPromiseAdapterTest.php index 436889f..294c11f 100644 --- a/tests/Executor/Promise/ReactPromiseAdapterTest.php +++ b/tests/Executor/Promise/ReactPromiseAdapterTest.php @@ -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() { diff --git a/tests/Executor/Promise/SyncPromiseAdapterTest.php b/tests/Executor/Promise/SyncPromiseAdapterTest.php index 491cb85..5aabf9d 100644 --- a/tests/Executor/Promise/SyncPromiseAdapterTest.php +++ b/tests/Executor/Promise/SyncPromiseAdapterTest.php @@ -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(''); } diff --git a/tests/Executor/Promise/SyncPromiseTest.php b/tests/Executor/Promise/SyncPromiseTest.php index 62d6e1f..d8f0840 100644 --- a/tests/Executor/Promise/SyncPromiseTest.php +++ b/tests/Executor/Promise/SyncPromiseTest.php @@ -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); diff --git a/tests/Executor/ResolveTest.php b/tests/Executor/ResolveTest.php index 37c6196..1301465 100644 --- a/tests/Executor/ResolveTest.php +++ b/tests/Executor/ResolveTest.php @@ -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 diff --git a/tests/Executor/UnionInterfaceTest.php b/tests/Executor/UnionInterfaceTest.php index 4c2b366..f6a9732 100644 --- a/tests/Executor/UnionInterfaceTest.php +++ b/tests/Executor/UnionInterfaceTest.php @@ -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; diff --git a/tests/Executor/ValuesTest.php b/tests/Executor/ValuesTest.php index 1fe81cf..4f8f8fa 100644 --- a/tests/Executor/ValuesTest.php +++ b/tests/Executor/ValuesTest.php @@ -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']); diff --git a/tests/Executor/VariablesTest.php b/tests/Executor/VariablesTest.php index 89c931f..397092e 100644 --- a/tests/Executor/VariablesTest.php +++ b/tests/Executor/VariablesTest.php @@ -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]); } diff --git a/tests/Language/LexerTest.php b/tests/Language/LexerTest.php index 4d62b5e..240409d 100644 --- a/tests/Language/LexerTest.php +++ b/tests/Language/LexerTest.php @@ -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) { diff --git a/tests/Language/ParserTest.php b/tests/Language/ParserTest.php index b34cd9a..9b0a1cb 100644 --- a/tests/Language/ParserTest.php +++ b/tests/Language/ParserTest.php @@ -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) { diff --git a/tests/Language/PrinterTest.php b/tests/Language/PrinterTest.php index 9d4cce2..0df809c 100644 --- a/tests/Language/PrinterTest.php +++ b/tests/Language/PrinterTest.php @@ -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); } diff --git a/tests/Language/SchemaParserTest.php b/tests/Language/SchemaParserTest.php index b7d018a..c916add 100644 --- a/tests/Language/SchemaParserTest.php +++ b/tests/Language/SchemaParserTest.php @@ -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) { diff --git a/tests/Language/SchemaPrinterTest.php b/tests/Language/SchemaPrinterTest.php index 1e1b897..c067d83 100644 --- a/tests/Language/SchemaPrinterTest.php +++ b/tests/Language/SchemaPrinterTest.php @@ -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); } diff --git a/tests/Language/SerializationTest.php b/tests/Language/SerializationTest.php index 3a5e166..f2fe16c 100644 --- a/tests/Language/SerializationTest.php +++ b/tests/Language/SerializationTest.php @@ -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() { diff --git a/tests/Language/TokenTest.php b/tests/Language/TokenTest.php index f93a717..541a618 100644 --- a/tests/Language/TokenTest.php +++ b/tests/Language/TokenTest.php @@ -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() { diff --git a/tests/Language/VisitorTest.php b/tests/Language/VisitorTest.php index df78b55..4ed2805 100644 --- a/tests/Language/VisitorTest.php +++ b/tests/Language/VisitorTest.php @@ -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 }' diff --git a/tests/Server/PsrResponseTest.php b/tests/Server/PsrResponseTest.php index 6c45335..9988d55 100644 --- a/tests/Server/PsrResponseTest.php +++ b/tests/Server/PsrResponseTest.php @@ -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() { diff --git a/tests/Server/QueryExecutionTest.php b/tests/Server/QueryExecutionTest.php index 487d089..1381eda 100644 --- a/tests/Server/QueryExecutionTest.php +++ b/tests/Server/QueryExecutionTest.php @@ -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,9 +319,9 @@ class QueryExecutionTest extends TestCase public function testProhibitsInvalidPersistedQueryLoader() { - $this->setExpectedException( - InvariantViolation::class, - 'Persistent query loader must return query string or instance of GraphQL\Language\AST\DocumentNode '. + $this->expectException(InvariantViolation::class); + $this->expectExceptionMessage( + 'Persistent query loader must return query string or instance of GraphQL\Language\AST\DocumentNode ' . 'but got: {"err":"err"}' ); $this->config->setPersistentQueryLoader(function($queryId, OperationParams $params) use (&$called) { @@ -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(); }); diff --git a/tests/Server/RequestParsingTest.php b/tests/Server/RequestParsingTest.php index c32a3ab..aca363d 100644 --- a/tests/Server/RequestParsingTest.php +++ b/tests/Server/RequestParsingTest.php @@ -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"); } diff --git a/tests/Server/RequestValidationTest.php b/tests/Server/RequestValidationTest.php index 0705871..de067b3 100644 --- a/tests/Server/RequestValidationTest.php +++ b/tests/Server/RequestValidationTest.php @@ -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() { diff --git a/tests/Server/ServerConfigTest.php b/tests/Server/ServerConfigTest.php index 3e2da61..8e78f8f 100644 --- a/tests/Server/ServerConfigTest.php +++ b/tests/Server/ServerConfigTest.php @@ -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); } diff --git a/tests/Server/TestCase.php b/tests/Server/ServerTestCase.php similarity index 97% rename from tests/Server/TestCase.php rename to tests/Server/ServerTestCase.php index c9dcca6..e76d8f4 100644 --- a/tests/Server/TestCase.php +++ b/tests/Server/ServerTestCase.php @@ -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() { diff --git a/tests/Server/StandardServerTest.php b/tests/Server/StandardServerTest.php index cc4adff..3f9398b 100644 --- a/tests/Server/StandardServerTest.php +++ b/tests/Server/StandardServerTest.php @@ -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 diff --git a/tests/StarWarsIntrospectionTest.php b/tests/StarWarsIntrospectionTest.php index 78527eb..0552e5d 100644 --- a/tests/StarWarsIntrospectionTest.php +++ b/tests/StarWarsIntrospectionTest.php @@ -1,10 +1,10 @@ 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); } } diff --git a/tests/Type/ResolveInfoTest.php b/tests/Type/ResolveInfoTest.php index 4aea85f..d770a40 100644 --- a/tests/Type/ResolveInfoTest.php +++ b/tests/Type/ResolveInfoTest.php @@ -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() { diff --git a/tests/Type/ScalarSerializationTest.php b/tests/Type/ScalarSerializationTest.php index 8b42d55..b2c41cc 100644 --- a/tests/Type/ScalarSerializationTest.php +++ b/tests/Type/ScalarSerializationTest.php @@ -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()); } } diff --git a/tests/Type/TypeLoaderTest.php b/tests/Type/TypeLoaderTest.php index db9cb06..8368b7e 100644 --- a/tests/Type/TypeLoaderTest.php +++ b/tests/Type/TypeLoaderTest.php @@ -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'); } diff --git a/tests/Type/ValidationTest.php b/tests/Type/ValidationTest.php index 361607a..3ea4ecd 100644 --- a/tests/Type/ValidationTest.php +++ b/tests/Type/ValidationTest.php @@ -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.' ); diff --git a/tests/Utils/AssertValidNameTest.php b/tests/Utils/AssertValidNameTest.php index 50899f7..d1f963c 100644 --- a/tests/Utils/AssertValidNameTest.php +++ b/tests/Utils/AssertValidNameTest.php @@ -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('>--()-->'); } } diff --git a/tests/Utils/AstFromValueTest.php b/tests/Utils/AstFromValueTest.php index 54c1410..952bba4 100644 --- a/tests/Utils/AstFromValueTest.php +++ b/tests/Utils/AstFromValueTest.php @@ -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 } diff --git a/tests/Utils/AstFromValueUntypedTest.php b/tests/Utils/AstFromValueUntypedTest.php index 53c81da..d82c5f5 100644 --- a/tests/Utils/AstFromValueUntypedTest.php +++ b/tests/Utils/AstFromValueUntypedTest.php @@ -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 diff --git a/tests/Utils/BuildSchemaTest.php b/tests/Utils/BuildSchemaTest.php index 916f377..e91f9fb 100644 --- a/tests/Utils/BuildSchemaTest.php +++ b/tests/Utils/BuildSchemaTest.php @@ -1,6 +1,7 @@ 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); } diff --git a/tests/Utils/CoerceValueTest.php b/tests/Utils/CoerceValueTest.php index bb5823a..d17f15a 100644 --- a/tests/Utils/CoerceValueTest.php +++ b/tests/Utils/CoerceValueTest.php @@ -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; diff --git a/tests/Utils/ExtractTypesTest.php b/tests/Utils/ExtractTypesTest.php index 6801f2f..5e2b093 100644 --- a/tests/Utils/ExtractTypesTest.php +++ b/tests/Utils/ExtractTypesTest.php @@ -1,14 +1,16 @@ 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); } } diff --git a/tests/Utils/FindBreakingChangesTest.php b/tests/Utils/FindBreakingChangesTest.php index 60134a0..fb8ae57 100644 --- a/tests/Utils/FindBreakingChangesTest.php +++ b/tests/Utils/FindBreakingChangesTest.php @@ -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; diff --git a/tests/Utils/IsValidLiteralValueTest.php b/tests/Utils/IsValidLiteralValueTest.php index 33b0592..2e82cfc 100644 --- a/tests/Utils/IsValidLiteralValueTest.php +++ b/tests/Utils/IsValidLiteralValueTest.php @@ -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 diff --git a/tests/Utils/MixedStoreTest.php b/tests/Utils/MixedStoreTest.php index 3f2fe3e..a5d0054 100644 --- a/tests/Utils/MixedStoreTest.php +++ b/tests/Utils/MixedStoreTest.php @@ -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 diff --git a/tests/Utils/QuotedOrListTest.php b/tests/Utils/QuotedOrListTest.php index d739c4c..cfa05da 100644 --- a/tests/Utils/QuotedOrListTest.php +++ b/tests/Utils/QuotedOrListTest.php @@ -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([]); } diff --git a/tests/Utils/SchemaPrinterTest.php b/tests/Utils/SchemaPrinterTest.php index 5c459ce..6c04696 100644 --- a/tests/Utils/SchemaPrinterTest.php +++ b/tests/Utils/SchemaPrinterTest.php @@ -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 diff --git a/tests/Utils/SuggestionListTest.php b/tests/Utils/SuggestionListTest.php index 73797f7..7c01235 100644 --- a/tests/Utils/SuggestionListTest.php +++ b/tests/Utils/SuggestionListTest.php @@ -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 diff --git a/tests/Utils/ValueFromAstTest.php b/tests/Utils/ValueFromAstTest.php index fc8870e..c70dad5 100644 --- a/tests/Utils/ValueFromAstTest.php +++ b/tests/Utils/ValueFromAstTest.php @@ -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) { diff --git a/tests/UtilsTest.php b/tests/UtilsTest.php index 7dbc795..84b5e03 100644 --- a/tests/UtilsTest.php +++ b/tests/UtilsTest.php @@ -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']); } } diff --git a/tests/Validator/DisableIntrospectionTest.php b/tests/Validator/DisableIntrospectionTest.php index 88d771c..bb1cf3e 100644 --- a/tests/Validator/DisableIntrospectionTest.php +++ b/tests/Validator/DisableIntrospectionTest.php @@ -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 diff --git a/tests/Validator/ExecutableDefinitionsTest.php b/tests/Validator/ExecutableDefinitionsTest.php index 2b9eda3..d6f672b 100644 --- a/tests/Validator/ExecutableDefinitionsTest.php +++ b/tests/Validator/ExecutableDefinitionsTest.php @@ -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 diff --git a/tests/Validator/FieldsOnCorrectTypeTest.php b/tests/Validator/FieldsOnCorrectTypeTest.php index 75a891e..ab12cc9 100644 --- a/tests/Validator/FieldsOnCorrectTypeTest.php +++ b/tests/Validator/FieldsOnCorrectTypeTest.php @@ -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 diff --git a/tests/Validator/FragmentsOnCompositeTypesTest.php b/tests/Validator/FragmentsOnCompositeTypesTest.php index 495f44b..d18d185 100644 --- a/tests/Validator/FragmentsOnCompositeTypesTest.php +++ b/tests/Validator/FragmentsOnCompositeTypesTest.php @@ -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 diff --git a/tests/Validator/KnownArgumentNamesTest.php b/tests/Validator/KnownArgumentNamesTest.php index 84b7e38..9347130 100644 --- a/tests/Validator/KnownArgumentNamesTest.php +++ b/tests/Validator/KnownArgumentNamesTest.php @@ -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: diff --git a/tests/Validator/KnownDirectivesTest.php b/tests/Validator/KnownDirectivesTest.php index 9374b73..9bfddb4 100644 --- a/tests/Validator/KnownDirectivesTest.php +++ b/tests/Validator/KnownDirectivesTest.php @@ -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 diff --git a/tests/Validator/KnownFragmentNamesTest.php b/tests/Validator/KnownFragmentNamesTest.php index 0a7e434..1b953f7 100644 --- a/tests/Validator/KnownFragmentNamesTest.php +++ b/tests/Validator/KnownFragmentNamesTest.php @@ -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 diff --git a/tests/Validator/KnownTypeNamesTest.php b/tests/Validator/KnownTypeNamesTest.php index f8aba61..21bcb44 100644 --- a/tests/Validator/KnownTypeNamesTest.php +++ b/tests/Validator/KnownTypeNamesTest.php @@ -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 diff --git a/tests/Validator/LoneAnonymousOperationTest.php b/tests/Validator/LoneAnonymousOperationTest.php index 584d65e..4aa975c 100644 --- a/tests/Validator/LoneAnonymousOperationTest.php +++ b/tests/Validator/LoneAnonymousOperationTest.php @@ -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 @@ -124,4 +124,4 @@ class LoneAnonymousOperationTest extends TestCase ); } -} \ No newline at end of file +} diff --git a/tests/Validator/NoFragmentCyclesTest.php b/tests/Validator/NoFragmentCyclesTest.php index f693d2c..43ad762 100644 --- a/tests/Validator/NoFragmentCyclesTest.php +++ b/tests/Validator/NoFragmentCyclesTest.php @@ -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 diff --git a/tests/Validator/NoUndefinedVariablesTest.php b/tests/Validator/NoUndefinedVariablesTest.php index 24b8a9f..328b24d 100644 --- a/tests/Validator/NoUndefinedVariablesTest.php +++ b/tests/Validator/NoUndefinedVariablesTest.php @@ -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 diff --git a/tests/Validator/NoUnusedFragmentsTest.php b/tests/Validator/NoUnusedFragmentsTest.php index f03b28e..be822b6 100644 --- a/tests/Validator/NoUnusedFragmentsTest.php +++ b/tests/Validator/NoUnusedFragmentsTest.php @@ -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 diff --git a/tests/Validator/NoUnusedVariablesTest.php b/tests/Validator/NoUnusedVariablesTest.php index bbdc0fa..b097e67 100644 --- a/tests/Validator/NoUnusedVariablesTest.php +++ b/tests/Validator/NoUnusedVariablesTest.php @@ -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 diff --git a/tests/Validator/OverlappingFieldsCanBeMergedTest.php b/tests/Validator/OverlappingFieldsCanBeMergedTest.php index 399af6a..ddd5267 100644 --- a/tests/Validator/OverlappingFieldsCanBeMergedTest.php +++ b/tests/Validator/OverlappingFieldsCanBeMergedTest.php @@ -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 diff --git a/tests/Validator/PossibleFragmentSpreadsTest.php b/tests/Validator/PossibleFragmentSpreadsTest.php index a3139de..d7b2234 100644 --- a/tests/Validator/PossibleFragmentSpreadsTest.php +++ b/tests/Validator/PossibleFragmentSpreadsTest.php @@ -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 diff --git a/tests/Validator/ProvidedNonNullArgumentsTest.php b/tests/Validator/ProvidedNonNullArgumentsTest.php index 020aefb..dc2dc5c 100644 --- a/tests/Validator/ProvidedNonNullArgumentsTest.php +++ b/tests/Validator/ProvidedNonNullArgumentsTest.php @@ -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 diff --git a/tests/Validator/QueryComplexityTest.php b/tests/Validator/QueryComplexityTest.php index fb1a8d7..ed6d74f 100644 --- a/tests/Validator/QueryComplexityTest.php +++ b/tests/Validator/QueryComplexityTest.php @@ -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), diff --git a/tests/Validator/QueryDepthTest.php b/tests/Validator/QueryDepthTest.php index c6ebda2..5f63936 100644 --- a/tests/Validator/QueryDepthTest.php +++ b/tests/Validator/QueryDepthTest.php @@ -3,7 +3,7 @@ namespace GraphQL\Tests\Validator; use GraphQL\Validator\Rules\QueryDepth; -class QueryDepthTest extends AbstractQuerySecurityTest +class QueryDepthTest extends QuerySecurityTestCase { /** * @param $max diff --git a/tests/Validator/AbstractQuerySecurityTest.php b/tests/Validator/QuerySecurityTestCase.php similarity index 96% rename from tests/Validator/AbstractQuerySecurityTest.php rename to tests/Validator/QuerySecurityTestCase.php index 7e5e36b..cfdb29a 100644 --- a/tests/Validator/AbstractQuerySecurityTest.php +++ b/tests/Validator/QuerySecurityTestCase.php @@ -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 diff --git a/tests/Validator/ScalarLeafsTest.php b/tests/Validator/ScalarLeafsTest.php index d6ea901..b8bf115 100644 --- a/tests/Validator/ScalarLeafsTest.php +++ b/tests/Validator/ScalarLeafsTest.php @@ -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 diff --git a/tests/Validator/UniqueArgumentNamesTest.php b/tests/Validator/UniqueArgumentNamesTest.php index bf13064..3646896 100644 --- a/tests/Validator/UniqueArgumentNamesTest.php +++ b/tests/Validator/UniqueArgumentNamesTest.php @@ -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 diff --git a/tests/Validator/UniqueDirectivesPerLocationTest.php b/tests/Validator/UniqueDirectivesPerLocationTest.php index 84662f1..9bd324b 100644 --- a/tests/Validator/UniqueDirectivesPerLocationTest.php +++ b/tests/Validator/UniqueDirectivesPerLocationTest.php @@ -3,7 +3,7 @@ namespace GraphQL\Tests\Validator; use GraphQL\Validator\Rules\UniqueDirectivesPerLocation; -class UniqueDirectivesPerLocationTest extends TestCase +class UniqueDirectivesPerLocationTest extends ValidatorTestCase { /** * @it no directives diff --git a/tests/Validator/UniqueFragmentNamesTest.php b/tests/Validator/UniqueFragmentNamesTest.php index ebc44c7..28e1b12 100644 --- a/tests/Validator/UniqueFragmentNamesTest.php +++ b/tests/Validator/UniqueFragmentNamesTest.php @@ -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 diff --git a/tests/Validator/UniqueInputFieldNamesTest.php b/tests/Validator/UniqueInputFieldNamesTest.php index 031dd0f..60f227c 100644 --- a/tests/Validator/UniqueInputFieldNamesTest.php +++ b/tests/Validator/UniqueInputFieldNamesTest.php @@ -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 diff --git a/tests/Validator/UniqueOperationNamesTest.php b/tests/Validator/UniqueOperationNamesTest.php index 67b9d39..a512b11 100644 --- a/tests/Validator/UniqueOperationNamesTest.php +++ b/tests/Validator/UniqueOperationNamesTest.php @@ -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 diff --git a/tests/Validator/UniqueVariableNamesTest.php b/tests/Validator/UniqueVariableNamesTest.php index 8c86817..d349a0a 100644 --- a/tests/Validator/UniqueVariableNamesTest.php +++ b/tests/Validator/UniqueVariableNamesTest.php @@ -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 diff --git a/tests/Validator/ValidationTest.php b/tests/Validator/ValidationTest.php index 51c7dbf..cf99783 100644 --- a/tests/Validator/ValidationTest.php +++ b/tests/Validator/ValidationTest.php @@ -1,7 +1,7 @@