mirror of
https://github.com/retailcrm/graphql-php.git
synced 2025-02-06 15:59:24 +03:00
Include expected type in isValidPHPValue error message
This commit is contained in:
parent
e30f2a99cf
commit
445f579f09
@ -248,7 +248,7 @@ class Values
|
||||
// a non-null value.
|
||||
$parseResult = $type->parseValue($value);
|
||||
if (null === $parseResult) {
|
||||
$v = json_encode($value);
|
||||
$v = Utils::printSafe($value);
|
||||
return [
|
||||
"Expected type \"{$type->name}\", found $v."
|
||||
];
|
||||
@ -256,10 +256,12 @@ class Values
|
||||
return [];
|
||||
} catch (\Exception $e) {
|
||||
return [
|
||||
"Expected type \"{$type->name}\", found " . Utils::printSafe($value) . ': ' .
|
||||
$e->getMessage()
|
||||
];
|
||||
} catch (\Throwable $e) {
|
||||
return [
|
||||
"Expected type \"{$type->name}\", found " . Utils::printSafe($value) . ': ' .
|
||||
$e->getMessage()
|
||||
];
|
||||
}
|
||||
|
@ -253,6 +253,9 @@ class Utils
|
||||
if ('' === $var) {
|
||||
return '(empty string)';
|
||||
}
|
||||
if (is_string($var)) {
|
||||
return "\"$var\"";
|
||||
}
|
||||
if (is_scalar($var)) {
|
||||
return (string) $var;
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ class EnumTypeTest extends \PHPUnit_Framework_TestCase
|
||||
'{ colorEnum(fromString: "GREEN") }',
|
||||
null,
|
||||
[
|
||||
'message' => 'Expected a value of type "Color" but received: GREEN',
|
||||
'message' => 'Expected a value of type "Color" but received: "GREEN"',
|
||||
'locations' => [new SourceLocation(1, 3)]
|
||||
]
|
||||
);
|
||||
@ -447,7 +447,7 @@ class EnumTypeTest extends \PHPUnit_Framework_TestCase
|
||||
[
|
||||
'data' => ['first' => 'ONE', 'second' => 'TWO', 'third' => null],
|
||||
'errors' => [[
|
||||
'message' => 'Expected a value of type "SimpleEnum" but received: WRONG',
|
||||
'message' => 'Expected a value of type "SimpleEnum" but received: "WRONG"',
|
||||
'locations' => [['line' => 4, 'column' => 13]]
|
||||
]]
|
||||
],
|
||||
|
@ -59,7 +59,7 @@ class ScalarSerializationTest extends \PHPUnit_Framework_TestCase
|
||||
$intType->serialize('one');
|
||||
$this->fail('Expected exception was not thrown');
|
||||
} catch (UserError $e) {
|
||||
$this->assertEquals('Int cannot represent non 32-bit signed integer value: one', $e->getMessage());
|
||||
$this->assertEquals('Int cannot represent non 32-bit signed integer value: "one"', $e->getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
@ -93,7 +93,7 @@ class ScalarSerializationTest extends \PHPUnit_Framework_TestCase
|
||||
$floatType->serialize('one');
|
||||
$this->fail('Expected exception was not thrown');
|
||||
} catch (UserError $e) {
|
||||
$this->assertEquals('Float cannot represent non numeric value: one', $e->getMessage());
|
||||
$this->assertEquals('Float cannot represent non numeric value: "one"', $e->getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user