mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-29 00:25:17 +03:00
Fixed tests for PHPUnit 7+
This commit is contained in:
parent
4227404aee
commit
c3d69c7c2b
@ -97,6 +97,7 @@ fragment MissingOn Type
|
|||||||
*/
|
*/
|
||||||
public function testParsesVariableInlineValues()
|
public function testParsesVariableInlineValues()
|
||||||
{
|
{
|
||||||
|
$this->expectNotToPerformAssertions();
|
||||||
// Following line should not throw:
|
// Following line should not throw:
|
||||||
Parser::parse('{ field(complex: { a: { b: [ $var ] } }) }');
|
Parser::parse('{ field(complex: { a: { b: [ $var ] } }) }');
|
||||||
}
|
}
|
||||||
@ -221,6 +222,7 @@ fragment $fragmentName on Type {
|
|||||||
*/
|
*/
|
||||||
public function testParsessAnonymousMutationOperations()
|
public function testParsessAnonymousMutationOperations()
|
||||||
{
|
{
|
||||||
|
$this->expectNotToPerformAssertions();
|
||||||
// Should not throw:
|
// Should not throw:
|
||||||
Parser::parse('
|
Parser::parse('
|
||||||
mutation {
|
mutation {
|
||||||
@ -234,6 +236,7 @@ fragment $fragmentName on Type {
|
|||||||
*/
|
*/
|
||||||
public function testParsesAnonymousSubscriptionOperations()
|
public function testParsesAnonymousSubscriptionOperations()
|
||||||
{
|
{
|
||||||
|
$this->expectNotToPerformAssertions();
|
||||||
// Should not throw:
|
// Should not throw:
|
||||||
Parser::parse('
|
Parser::parse('
|
||||||
subscription {
|
subscription {
|
||||||
@ -247,6 +250,7 @@ fragment $fragmentName on Type {
|
|||||||
*/
|
*/
|
||||||
public function testParsesNamedMutationOperations()
|
public function testParsesNamedMutationOperations()
|
||||||
{
|
{
|
||||||
|
$this->expectNotToPerformAssertions();
|
||||||
// Should not throw:
|
// Should not throw:
|
||||||
Parser::parse('
|
Parser::parse('
|
||||||
mutation Foo {
|
mutation Foo {
|
||||||
@ -260,6 +264,7 @@ fragment $fragmentName on Type {
|
|||||||
*/
|
*/
|
||||||
public function testParsesNamedSubscriptionOperations()
|
public function testParsesNamedSubscriptionOperations()
|
||||||
{
|
{
|
||||||
|
$this->expectNotToPerformAssertions();
|
||||||
Parser::parse('
|
Parser::parse('
|
||||||
subscription Foo {
|
subscription Foo {
|
||||||
subscriptionField
|
subscriptionField
|
||||||
|
@ -137,10 +137,7 @@ class RequestValidationTest extends TestCase
|
|||||||
{
|
{
|
||||||
$helper = new Helper();
|
$helper = new Helper();
|
||||||
$errors = $helper->validateOperationParams($parsedRequest);
|
$errors = $helper->validateOperationParams($parsedRequest);
|
||||||
|
$this->assertEmpty($errors, isset($errors[0]) ? $errors[0]->getMessage() : '');
|
||||||
if (!empty($errors)) {
|
|
||||||
throw $errors[0];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function assertInputError($parsedRequest, $expectedMessage)
|
private function assertInputError($parsedRequest, $expectedMessage)
|
||||||
|
@ -515,8 +515,8 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testProhibitsNestingNonNullInsideNonNull()
|
public function testProhibitsNestingNonNullInsideNonNull()
|
||||||
{
|
{
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'Expected Int! to be a GraphQL nullable type.'
|
'Expected Int! to be a GraphQL nullable type.'
|
||||||
);
|
);
|
||||||
Type::nonNull(Type::nonNull(Type::int()));
|
Type::nonNull(Type::nonNull(Type::int()));
|
||||||
@ -771,8 +771,8 @@ class DefinitionTest extends TestCase
|
|||||||
'f' => null,
|
'f' => null,
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'SomeObject.f field config must be an array, but got: null'
|
'SomeObject.f field config must be an array, but got: null'
|
||||||
);
|
);
|
||||||
$objType->getFields();
|
$objType->getFields();
|
||||||
@ -787,8 +787,8 @@ class DefinitionTest extends TestCase
|
|||||||
'name' => 'SomeObject',
|
'name' => 'SomeObject',
|
||||||
'fields' => [['field' => Type::string()]],
|
'fields' => [['field' => Type::string()]],
|
||||||
]);
|
]);
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'SomeObject fields must be an associative array with field names as keys or a ' .
|
'SomeObject fields must be an associative array with field names as keys or a ' .
|
||||||
'function which returns such an array.'
|
'function which returns such an array.'
|
||||||
);
|
);
|
||||||
@ -806,8 +806,8 @@ class DefinitionTest extends TestCase
|
|||||||
return [['field' => Type::string()]];
|
return [['field' => Type::string()]];
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'SomeObject fields must be an associative array with field names as keys or a ' .
|
'SomeObject fields must be an associative array with field names as keys or a ' .
|
||||||
'function which returns such an array.'
|
'function which returns such an array.'
|
||||||
);
|
);
|
||||||
@ -821,6 +821,7 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testAcceptsAnObjectTypeWithFieldArgs()
|
public function testAcceptsAnObjectTypeWithFieldArgs()
|
||||||
{
|
{
|
||||||
|
$this->expectNotToPerformAssertions();
|
||||||
$objType = new ObjectType([
|
$objType = new ObjectType([
|
||||||
'name' => 'SomeObject',
|
'name' => 'SomeObject',
|
||||||
'fields' => [
|
'fields' => [
|
||||||
@ -833,7 +834,7 @@ class DefinitionTest extends TestCase
|
|||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
// Should not throw:
|
// Should not throw:
|
||||||
$objType->assertValid(true);
|
$objType->assertValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
// rejects an Object type with incorrectly typed field args
|
// rejects an Object type with incorrectly typed field args
|
||||||
@ -853,12 +854,11 @@ class DefinitionTest extends TestCase
|
|||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'OldObject.field should provide "deprecationReason" instead of "isDeprecated".'
|
'OldObject.field should provide "deprecationReason" instead of "isDeprecated".'
|
||||||
);
|
);
|
||||||
|
$OldObject->assertValid();
|
||||||
$OldObject->assertValid(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Object interfaces must be array
|
// Object interfaces must be array
|
||||||
@ -901,8 +901,8 @@ class DefinitionTest extends TestCase
|
|||||||
'interfaces' => new \stdClass(),
|
'interfaces' => new \stdClass(),
|
||||||
'fields' => ['f' => ['type' => Type::string()]],
|
'fields' => ['f' => ['type' => Type::string()]],
|
||||||
]);
|
]);
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'SomeObject interfaces must be an Array or a callable which returns an Array.'
|
'SomeObject interfaces must be an Array or a callable which returns an Array.'
|
||||||
);
|
);
|
||||||
$objType->getInterfaces();
|
$objType->getInterfaces();
|
||||||
@ -920,8 +920,8 @@ class DefinitionTest extends TestCase
|
|||||||
},
|
},
|
||||||
'fields' => ['f' => ['type' => Type::string()]],
|
'fields' => ['f' => ['type' => Type::string()]],
|
||||||
]);
|
]);
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'SomeObject interfaces must be an Array or a callable which returns an Array.'
|
'SomeObject interfaces must be an Array or a callable which returns an Array.'
|
||||||
);
|
);
|
||||||
$objType->getInterfaces();
|
$objType->getInterfaces();
|
||||||
@ -958,6 +958,7 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testAcceptsALambdaAsAnObjectFieldResolver()
|
public function testAcceptsALambdaAsAnObjectFieldResolver()
|
||||||
{
|
{
|
||||||
|
$this->expectNotToPerformAssertions();
|
||||||
// should not throw:
|
// should not throw:
|
||||||
$this->schemaWithObjectWithFieldResolver(function () {});
|
$this->schemaWithObjectWithFieldResolver(function () {});
|
||||||
}
|
}
|
||||||
@ -967,8 +968,8 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testRejectsAnEmptyObjectFieldResolver()
|
public function testRejectsAnEmptyObjectFieldResolver()
|
||||||
{
|
{
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'BadResolver.badField field resolver must be a function if provided, but got: []'
|
'BadResolver.badField field resolver must be a function if provided, but got: []'
|
||||||
);
|
);
|
||||||
$this->schemaWithObjectWithFieldResolver([]);
|
$this->schemaWithObjectWithFieldResolver([]);
|
||||||
@ -979,8 +980,8 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testRejectsAConstantScalarValueResolver()
|
public function testRejectsAConstantScalarValueResolver()
|
||||||
{
|
{
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'BadResolver.badField field resolver must be a function if provided, but got: 0'
|
'BadResolver.badField field resolver must be a function if provided, but got: 0'
|
||||||
);
|
);
|
||||||
$this->schemaWithObjectWithFieldResolver(0);
|
$this->schemaWithObjectWithFieldResolver(0);
|
||||||
@ -1006,6 +1007,7 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testAcceptsAnInterfaceTypeDefiningResolveType()
|
public function testAcceptsAnInterfaceTypeDefiningResolveType()
|
||||||
{
|
{
|
||||||
|
$this->expectNotToPerformAssertions();
|
||||||
$AnotherInterfaceType = new InterfaceType([
|
$AnotherInterfaceType = new InterfaceType([
|
||||||
'name' => 'AnotherInterface',
|
'name' => 'AnotherInterface',
|
||||||
'fields' => ['f' => ['type' => Type::string()]],
|
'fields' => ['f' => ['type' => Type::string()]],
|
||||||
@ -1026,6 +1028,7 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testAcceptsAnInterfaceWithImplementingTypeDefiningIsTypeOf()
|
public function testAcceptsAnInterfaceWithImplementingTypeDefiningIsTypeOf()
|
||||||
{
|
{
|
||||||
|
$this->expectNotToPerformAssertions();
|
||||||
$InterfaceTypeWithoutResolveType = new InterfaceType([
|
$InterfaceTypeWithoutResolveType = new InterfaceType([
|
||||||
'name' => 'InterfaceTypeWithoutResolveType',
|
'name' => 'InterfaceTypeWithoutResolveType',
|
||||||
'fields' => ['f' => ['type' => Type::string()]],
|
'fields' => ['f' => ['type' => Type::string()]],
|
||||||
@ -1046,6 +1049,7 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testAcceptsAnInterfaceTypeDefiningResolveTypeWithImplementingTypeDefiningIsTypeOf()
|
public function testAcceptsAnInterfaceTypeDefiningResolveTypeWithImplementingTypeDefiningIsTypeOf()
|
||||||
{
|
{
|
||||||
|
$this->expectNotToPerformAssertions();
|
||||||
$AnotherInterfaceType = new InterfaceType([
|
$AnotherInterfaceType = new InterfaceType([
|
||||||
'name' => 'AnotherInterface',
|
'name' => 'AnotherInterface',
|
||||||
'fields' => ['f' => ['type' => Type::string()]],
|
'fields' => ['f' => ['type' => Type::string()]],
|
||||||
@ -1066,8 +1070,8 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testRejectsAnInterfaceTypeWithAnIncorrectTypeForResolveType()
|
public function testRejectsAnInterfaceTypeWithAnIncorrectTypeForResolveType()
|
||||||
{
|
{
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'AnotherInterface must provide "resolveType" as a function, but got: instance of stdClass'
|
'AnotherInterface must provide "resolveType" as a function, but got: instance of stdClass'
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1094,6 +1098,7 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testAcceptsAUnionTypeDefiningResolveType()
|
public function testAcceptsAUnionTypeDefiningResolveType()
|
||||||
{
|
{
|
||||||
|
$this->expectNotToPerformAssertions();
|
||||||
// Should not throw:
|
// Should not throw:
|
||||||
$this->schemaWithFieldType(
|
$this->schemaWithFieldType(
|
||||||
new UnionType([
|
new UnionType([
|
||||||
@ -1108,6 +1113,7 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testAcceptsAUnionOfObjectTypesDefiningIsTypeOf()
|
public function testAcceptsAUnionOfObjectTypesDefiningIsTypeOf()
|
||||||
{
|
{
|
||||||
|
$this->expectNotToPerformAssertions();
|
||||||
// Should not throw:
|
// Should not throw:
|
||||||
$this->schemaWithFieldType(
|
$this->schemaWithFieldType(
|
||||||
new UnionType([
|
new UnionType([
|
||||||
@ -1122,6 +1128,7 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testAcceptsAUnionTypeDefiningResolveTypeOfObjectTypesDefiningIsTypeOf()
|
public function testAcceptsAUnionTypeDefiningResolveTypeOfObjectTypesDefiningIsTypeOf()
|
||||||
{
|
{
|
||||||
|
$this->expectNotToPerformAssertions();
|
||||||
// Should not throw:
|
// Should not throw:
|
||||||
$this->schemaWithFieldType(
|
$this->schemaWithFieldType(
|
||||||
new UnionType([
|
new UnionType([
|
||||||
@ -1136,8 +1143,8 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testRejectsAnUnionTypeWithAnIncorrectTypeForResolveType()
|
public function testRejectsAnUnionTypeWithAnIncorrectTypeForResolveType()
|
||||||
{
|
{
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'SomeUnion must provide "resolveType" as a function, but got: instance of stdClass'
|
'SomeUnion must provide "resolveType" as a function, but got: instance of stdClass'
|
||||||
);
|
);
|
||||||
$this->schemaWithFieldType(
|
$this->schemaWithFieldType(
|
||||||
@ -1156,6 +1163,7 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testAcceptsAScalarTypeDefiningSerialize()
|
public function testAcceptsAScalarTypeDefiningSerialize()
|
||||||
{
|
{
|
||||||
|
$this->expectNotToPerformAssertions();
|
||||||
// Should not throw
|
// Should not throw
|
||||||
$this->schemaWithFieldType(
|
$this->schemaWithFieldType(
|
||||||
new CustomScalarType([
|
new CustomScalarType([
|
||||||
@ -1172,8 +1180,8 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testRejectsAScalarTypeNotDefiningSerialize()
|
public function testRejectsAScalarTypeNotDefiningSerialize()
|
||||||
{
|
{
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'SomeScalar must provide "serialize" function. If this custom Scalar ' .
|
'SomeScalar must provide "serialize" function. If this custom Scalar ' .
|
||||||
'is also used as an input type, ensure "parseValue" and "parseLiteral" ' .
|
'is also used as an input type, ensure "parseValue" and "parseLiteral" ' .
|
||||||
'functions are also provided.'
|
'functions are also provided.'
|
||||||
@ -1190,8 +1198,8 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testRejectsAScalarTypeDefiningSerializeWithAnIncorrectType()
|
public function testRejectsAScalarTypeDefiningSerializeWithAnIncorrectType()
|
||||||
{
|
{
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'SomeScalar must provide "serialize" function. If this custom Scalar ' .
|
'SomeScalar must provide "serialize" function. If this custom Scalar ' .
|
||||||
'is also used as an input type, ensure "parseValue" and "parseLiteral" ' .
|
'is also used as an input type, ensure "parseValue" and "parseLiteral" ' .
|
||||||
'functions are also provided.'
|
'functions are also provided.'
|
||||||
@ -1209,6 +1217,7 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testAcceptsAScalarTypeDefiningParseValueAndParseLiteral()
|
public function testAcceptsAScalarTypeDefiningParseValueAndParseLiteral()
|
||||||
{
|
{
|
||||||
|
$this->expectNotToPerformAssertions();
|
||||||
// Should not throw:
|
// Should not throw:
|
||||||
$this->schemaWithFieldType(
|
$this->schemaWithFieldType(
|
||||||
new CustomScalarType([
|
new CustomScalarType([
|
||||||
@ -1228,8 +1237,8 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testRejectsAScalarTypeDefiningParseValueButNotParseLiteral()
|
public function testRejectsAScalarTypeDefiningParseValueButNotParseLiteral()
|
||||||
{
|
{
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'SomeScalar must provide both "parseValue" and "parseLiteral" functions.'
|
'SomeScalar must provide both "parseValue" and "parseLiteral" functions.'
|
||||||
);
|
);
|
||||||
$this->schemaWithFieldType(
|
$this->schemaWithFieldType(
|
||||||
@ -1248,8 +1257,8 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testRejectsAScalarTypeDefiningParseLiteralButNotParseValue()
|
public function testRejectsAScalarTypeDefiningParseLiteralButNotParseValue()
|
||||||
{
|
{
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'SomeScalar must provide both "parseValue" and "parseLiteral" functions.'
|
'SomeScalar must provide both "parseValue" and "parseLiteral" functions.'
|
||||||
);
|
);
|
||||||
$this->schemaWithFieldType(
|
$this->schemaWithFieldType(
|
||||||
@ -1268,8 +1277,8 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testRejectsAScalarTypeDefiningParseValueAndParseLiteralWithAnIncorrectType()
|
public function testRejectsAScalarTypeDefiningParseValueAndParseLiteralWithAnIncorrectType()
|
||||||
{
|
{
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'SomeScalar must provide both "parseValue" and "parseLiteral" functions.'
|
'SomeScalar must provide both "parseValue" and "parseLiteral" functions.'
|
||||||
);
|
);
|
||||||
$this->schemaWithFieldType(
|
$this->schemaWithFieldType(
|
||||||
@ -1290,6 +1299,7 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testAcceptsAnObjectTypeWithAnIsTypeOfFunction()
|
public function testAcceptsAnObjectTypeWithAnIsTypeOfFunction()
|
||||||
{
|
{
|
||||||
|
$this->expectNotToPerformAssertions();
|
||||||
// Should not throw
|
// Should not throw
|
||||||
$this->schemaWithFieldType(
|
$this->schemaWithFieldType(
|
||||||
new ObjectType([
|
new ObjectType([
|
||||||
@ -1304,8 +1314,8 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testRejectsAnObjectTypeWithAnIncorrectTypeForIsTypeOf()
|
public function testRejectsAnObjectTypeWithAnIncorrectTypeForIsTypeOf()
|
||||||
{
|
{
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'AnotherObject must provide "isTypeOf" as a function, but got: instance of stdClass'
|
'AnotherObject must provide "isTypeOf" as a function, but got: instance of stdClass'
|
||||||
);
|
);
|
||||||
$this->schemaWithFieldType(
|
$this->schemaWithFieldType(
|
||||||
@ -1324,6 +1334,7 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testAcceptsAUnionTypeWithArrayTypes()
|
public function testAcceptsAUnionTypeWithArrayTypes()
|
||||||
{
|
{
|
||||||
|
$this->expectNotToPerformAssertions();
|
||||||
// Should not throw:
|
// Should not throw:
|
||||||
$this->schemaWithFieldType(
|
$this->schemaWithFieldType(
|
||||||
new UnionType([
|
new UnionType([
|
||||||
@ -1338,6 +1349,7 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testAcceptsAUnionTypeWithFunctionReturningAnArrayOfTypes()
|
public function testAcceptsAUnionTypeWithFunctionReturningAnArrayOfTypes()
|
||||||
{
|
{
|
||||||
|
$this->expectNotToPerformAssertions();
|
||||||
$this->schemaWithFieldType(
|
$this->schemaWithFieldType(
|
||||||
new UnionType([
|
new UnionType([
|
||||||
'name' => 'SomeUnion',
|
'name' => 'SomeUnion',
|
||||||
@ -1353,8 +1365,8 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testRejectsAUnionTypeWithoutTypes()
|
public function testRejectsAUnionTypeWithoutTypes()
|
||||||
{
|
{
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'Must provide Array of types or a callable which returns such an array for Union SomeUnion'
|
'Must provide Array of types or a callable which returns such an array for Union SomeUnion'
|
||||||
);
|
);
|
||||||
$this->schemaWithFieldType(
|
$this->schemaWithFieldType(
|
||||||
@ -1369,8 +1381,8 @@ class DefinitionTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testRejectsAUnionTypeWithIncorrectlyTypedTypes()
|
public function testRejectsAUnionTypeWithIncorrectlyTypedTypes()
|
||||||
{
|
{
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'Must provide Array of types or a callable which returns such an array for Union SomeUnion'
|
'Must provide Array of types or a callable which returns such an array for Union SomeUnion'
|
||||||
);
|
);
|
||||||
$this->schemaWithFieldType(
|
$this->schemaWithFieldType(
|
||||||
@ -1424,8 +1436,8 @@ class DefinitionTest extends TestCase
|
|||||||
'name' => 'SomeInputObject',
|
'name' => 'SomeInputObject',
|
||||||
'fields' => [],
|
'fields' => [],
|
||||||
]);
|
]);
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'SomeInputObject fields must be an associative array with field names as keys or a callable '.
|
'SomeInputObject fields must be an associative array with field names as keys or a callable '.
|
||||||
'which returns such an array.'
|
'which returns such an array.'
|
||||||
);
|
);
|
||||||
@ -1443,8 +1455,8 @@ class DefinitionTest extends TestCase
|
|||||||
return [];
|
return [];
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'SomeInputObject fields must be an associative array with field names as keys or a ' .
|
'SomeInputObject fields must be an associative array with field names as keys or a ' .
|
||||||
'callable which returns such an array.'
|
'callable which returns such an array.'
|
||||||
);
|
);
|
||||||
@ -1469,8 +1481,8 @@ class DefinitionTest extends TestCase
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'SomeInputObject.f field type has a resolve property, ' .
|
'SomeInputObject.f field type has a resolve property, ' .
|
||||||
'but Input Types cannot define resolvers.'
|
'but Input Types cannot define resolvers.'
|
||||||
);
|
);
|
||||||
@ -1491,8 +1503,8 @@ class DefinitionTest extends TestCase
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'SomeInputObject.f field type has a resolve property, ' .
|
'SomeInputObject.f field type has a resolve property, ' .
|
||||||
'but Input Types cannot define resolvers.'
|
'but Input Types cannot define resolvers.'
|
||||||
);
|
);
|
||||||
@ -1542,8 +1554,8 @@ class DefinitionTest extends TestCase
|
|||||||
'name' => 'SomeEnum',
|
'name' => 'SomeEnum',
|
||||||
'values' => [['FOO' => 10]],
|
'values' => [['FOO' => 10]],
|
||||||
]);
|
]);
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'SomeEnum values must be an array with value names as keys.'
|
'SomeEnum values must be an array with value names as keys.'
|
||||||
);
|
);
|
||||||
$enumType->assertValid();
|
$enumType->assertValid();
|
||||||
@ -1562,8 +1574,8 @@ class DefinitionTest extends TestCase
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'SomeEnum.FOO should provide "deprecationReason" instead ' .
|
'SomeEnum.FOO should provide "deprecationReason" instead ' .
|
||||||
'of "isDeprecated".'
|
'of "isDeprecated".'
|
||||||
);
|
);
|
||||||
@ -1667,8 +1679,8 @@ class DefinitionTest extends TestCase
|
|||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'Schema must contain unique named types but contains multiple types named "String" '.
|
'Schema must contain unique named types but contains multiple types named "String" '.
|
||||||
'(see http://webonyx.github.io/graphql-php/type-system/#type-registry).'
|
'(see http://webonyx.github.io/graphql-php/type-system/#type-registry).'
|
||||||
);
|
);
|
||||||
@ -1698,8 +1710,8 @@ class DefinitionTest extends TestCase
|
|||||||
'b' => ['type' => $B],
|
'b' => ['type' => $B],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'Schema must contain unique named types but contains multiple types named "SameName" ' .
|
'Schema must contain unique named types but contains multiple types named "SameName" ' .
|
||||||
'(see http://webonyx.github.io/graphql-php/type-system/#type-registry).'
|
'(see http://webonyx.github.io/graphql-php/type-system/#type-registry).'
|
||||||
);
|
);
|
||||||
@ -1736,8 +1748,8 @@ class DefinitionTest extends TestCase
|
|||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->setExpectedException(
|
$this->expectException(InvariantViolation::class);
|
||||||
InvariantViolation::class,
|
$this->expectExceptionMessage(
|
||||||
'Schema must contain unique named types but contains multiple types named "BadObject" ' .
|
'Schema must contain unique named types but contains multiple types named "BadObject" ' .
|
||||||
'(see http://webonyx.github.io/graphql-php/type-system/#type-registry).'
|
'(see http://webonyx.github.io/graphql-php/type-system/#type-registry).'
|
||||||
);
|
);
|
||||||
|
@ -153,6 +153,7 @@ class TypeLoaderTest extends TestCase
|
|||||||
|
|
||||||
public function testSchemaAcceptsTypeLoader()
|
public function testSchemaAcceptsTypeLoader()
|
||||||
{
|
{
|
||||||
|
$this->expectNotToPerformAssertions();
|
||||||
new Schema([
|
new Schema([
|
||||||
'query' => new ObjectType([
|
'query' => new ObjectType([
|
||||||
'name' => 'Query',
|
'name' => 'Query',
|
||||||
|
@ -535,6 +535,7 @@ class ValidationTest extends TestCase
|
|||||||
|
|
||||||
public function testAcceptsShorthandNotationForFields()
|
public function testAcceptsShorthandNotationForFields()
|
||||||
{
|
{
|
||||||
|
$this->expectNotToPerformAssertions();
|
||||||
$schema = $this->schemaWithFieldType(
|
$schema = $this->schemaWithFieldType(
|
||||||
new ObjectType([
|
new ObjectType([
|
||||||
'name' => 'SomeObject',
|
'name' => 'SomeObject',
|
||||||
@ -1032,6 +1033,7 @@ class ValidationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testRejectsAnObjectImplementingTheSameInterfaceTwiceDueToExtension()
|
public function testRejectsAnObjectImplementingTheSameInterfaceTwiceDueToExtension()
|
||||||
{
|
{
|
||||||
|
$this->expectNotToPerformAssertions();
|
||||||
$this->markTestIncomplete('extend does not work this way (yet).');
|
$this->markTestIncomplete('extend does not work this way (yet).');
|
||||||
$schema = BuildSchema::build('
|
$schema = BuildSchema::build('
|
||||||
type Query {
|
type Query {
|
||||||
|
Loading…
Reference in New Issue
Block a user