mirror of
https://github.com/retailcrm/graphql-php.git
synced 2025-02-06 15:59:24 +03:00
Fixed tests broken by recent changes to serialized error format
This commit is contained in:
parent
c25a29213c
commit
6d7a4a4f34
@ -26,6 +26,7 @@ class Config
|
|||||||
const REQUIRED = 65536;
|
const REQUIRED = 65536;
|
||||||
const KEY_AS_NAME = 131072;
|
const KEY_AS_NAME = 131072;
|
||||||
const MAYBE_THUNK = 262144;
|
const MAYBE_THUNK = 262144;
|
||||||
|
const MAYBE_TYPE = 524288;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var bool
|
||||||
@ -155,7 +156,11 @@ class Config
|
|||||||
|
|
||||||
foreach ($value as $arrKey => $arrValue) {
|
foreach ($value as $arrKey => $arrValue) {
|
||||||
if (is_array($def->definition)) {
|
if (is_array($def->definition)) {
|
||||||
Utils::invariant(is_array($arrValue), $err, $arrKey, Utils::getVariableType($arrValue));
|
if ($def->flags & self::MAYBE_TYPE) {
|
||||||
|
Utils::invariant(is_array($arrValue) || $arrValue instanceof Type, $err, $arrKey, Utils::getVariableType($arrValue));
|
||||||
|
} else {
|
||||||
|
Utils::invariant(is_array($arrValue), $err, $arrKey, Utils::getVariableType($arrValue));
|
||||||
|
}
|
||||||
|
|
||||||
if ($def->flags & self::KEY_AS_NAME) {
|
if ($def->flags & self::KEY_AS_NAME) {
|
||||||
$arrValue += ['name' => $arrKey];
|
$arrValue += ['name' => $arrKey];
|
||||||
|
@ -86,7 +86,7 @@ class ObjectType extends Type implements OutputType, CompositeType
|
|||||||
'name' => Config::STRING | Config::REQUIRED,
|
'name' => Config::STRING | Config::REQUIRED,
|
||||||
'fields' => Config::arrayOf(
|
'fields' => Config::arrayOf(
|
||||||
FieldDefinition::getDefinition(),
|
FieldDefinition::getDefinition(),
|
||||||
Config::KEY_AS_NAME | Config::MAYBE_THUNK
|
Config::KEY_AS_NAME | Config::MAYBE_THUNK | Config::MAYBE_TYPE
|
||||||
),
|
),
|
||||||
'description' => Config::STRING,
|
'description' => Config::STRING,
|
||||||
'interfaces' => Config::arrayOf(
|
'interfaces' => Config::arrayOf(
|
||||||
|
@ -404,7 +404,7 @@ class ExecutorTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$result = Executor::execute($schema, $docAst, $data);
|
$result = Executor::execute($schema, $docAst, $data);
|
||||||
|
|
||||||
$this->assertEquals($expected, $result->toArray());
|
$this->assertArraySubset($expected, $result->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,7 +41,7 @@ class ListsTest extends \PHPUnit_Framework_TestCase
|
|||||||
$ast = Parser::parse('{ nest { test } }');
|
$ast = Parser::parse('{ nest { test } }');
|
||||||
|
|
||||||
$result = Executor::execute($schema, $ast, $data);
|
$result = Executor::execute($schema, $ast, $data);
|
||||||
$this->assertEquals($expected, $result->toArray());
|
$this->assertArraySubset($expected, $result->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Describe: Execute: Handles list nullability
|
// Describe: Execute: Handles list nullability
|
||||||
|
@ -114,7 +114,7 @@ class MutationsTest extends \PHPUnit_Framework_TestCase
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
$this->assertEquals($expected, $mutationResult->toArray());
|
$this->assertArraySubset($expected, $mutationResult->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
private function schema()
|
private function schema()
|
||||||
|
@ -99,7 +99,7 @@ class NonNullTest extends \PHPUnit_Framework_TestCase
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
$this->assertEquals($expected, Executor::execute($this->schema, $ast, $this->throwingData, null, [], 'Q')->toArray());
|
$this->assertArraySubset($expected, Executor::execute($this->schema, $ast, $this->throwingData, null, [], 'Q')->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullsASynchronouslyReturnedObjectThatContainsANonNullableFieldThatThrowsSynchronously()
|
public function testNullsASynchronouslyReturnedObjectThatContainsANonNullableFieldThatThrowsSynchronously()
|
||||||
@ -123,7 +123,7 @@ class NonNullTest extends \PHPUnit_Framework_TestCase
|
|||||||
FormattedError::create($this->nonNullSyncError->getMessage(), [new SourceLocation(4, 11)])
|
FormattedError::create($this->nonNullSyncError->getMessage(), [new SourceLocation(4, 11)])
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
$this->assertEquals($expected, Executor::execute($this->schema, $ast, $this->throwingData, null, [], 'Q')->toArray());
|
$this->assertArraySubset($expected, Executor::execute($this->schema, $ast, $this->throwingData, null, [], 'Q')->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullsAComplexTreeOfNullableFieldsThatThrow()
|
public function testNullsAComplexTreeOfNullableFieldsThatThrow()
|
||||||
@ -155,7 +155,7 @@ class NonNullTest extends \PHPUnit_Framework_TestCase
|
|||||||
FormattedError::create($this->syncError->getMessage(), [new SourceLocation(6, 13)]),
|
FormattedError::create($this->syncError->getMessage(), [new SourceLocation(6, 13)]),
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
$this->assertEquals($expected, Executor::execute($this->schema, $ast, $this->throwingData, null, [], 'Q')->toArray());
|
$this->assertArraySubset($expected, Executor::execute($this->schema, $ast, $this->throwingData, null, [], 'Q')->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullsANullableFieldThatSynchronouslyReturnsNull()
|
public function testNullsANullableFieldThatSynchronouslyReturnsNull()
|
||||||
@ -197,7 +197,7 @@ class NonNullTest extends \PHPUnit_Framework_TestCase
|
|||||||
FormattedError::create('Cannot return null for non-nullable field DataType.nonNullSync.', [new SourceLocation(4, 11)])
|
FormattedError::create('Cannot return null for non-nullable field DataType.nonNullSync.', [new SourceLocation(4, 11)])
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
$this->assertEquals($expected, Executor::execute($this->schema, $ast, $this->nullingData, null, [], 'Q')->toArray());
|
$this->assertArraySubset($expected, Executor::execute($this->schema, $ast, $this->nullingData, null, [], 'Q')->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test5()
|
public function test5()
|
||||||
@ -247,7 +247,7 @@ class NonNullTest extends \PHPUnit_Framework_TestCase
|
|||||||
FormattedError::create($this->nonNullSyncError->getMessage(), [new SourceLocation(2, 17)])
|
FormattedError::create($this->nonNullSyncError->getMessage(), [new SourceLocation(2, 17)])
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
$this->assertEquals($expected, Executor::execute($this->schema, Parser::parse($doc), $this->throwingData)->toArray());
|
$this->assertArraySubset($expected, Executor::execute($this->schema, Parser::parse($doc), $this->throwingData)->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullsTheTopLevelIfSyncNonNullableFieldReturnsNull()
|
public function testNullsTheTopLevelIfSyncNonNullableFieldReturnsNull()
|
||||||
@ -262,6 +262,6 @@ class NonNullTest extends \PHPUnit_Framework_TestCase
|
|||||||
FormattedError::create('Cannot return null for non-nullable field DataType.nonNullSync.', [new SourceLocation(2, 17)]),
|
FormattedError::create('Cannot return null for non-nullable field DataType.nonNullSync.', [new SourceLocation(2, 17)]),
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
$this->assertEquals($expected, Executor::execute($this->schema, Parser::parse($doc), $this->nullingData)->toArray());
|
$this->assertArraySubset($expected, Executor::execute($this->schema, Parser::parse($doc), $this->nullingData)->toArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -423,7 +423,7 @@ class EnumTypeTest extends \PHPUnit_Framework_TestCase
|
|||||||
]]
|
]]
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertArraySubset($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -443,7 +443,7 @@ class EnumTypeTest extends \PHPUnit_Framework_TestCase
|
|||||||
third: simpleEnum(fromValue: "WRONG")
|
third: simpleEnum(fromValue: "WRONG")
|
||||||
}';
|
}';
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertArraySubset(
|
||||||
[
|
[
|
||||||
'data' => ['first' => 'ONE', 'second' => 'TWO', 'third' => null],
|
'data' => ['first' => 'ONE', 'second' => 'TWO', 'third' => null],
|
||||||
'errors' => [[
|
'errors' => [[
|
||||||
|
Loading…
x
Reference in New Issue
Block a user