mirror of
https://github.com/retailcrm/graphql-php.git
synced 2025-02-21 06:43:14 +03:00
Reverted unnecessary breaking change
This commit is contained in:
parent
88c959edad
commit
f369d4e2d4
@ -72,12 +72,10 @@ class EnumType extends Type implements InputType, OutputType, LeafType
|
|||||||
foreach ($config['values'] as $name => $value) {
|
foreach ($config['values'] as $name => $value) {
|
||||||
if (is_string($name)) {
|
if (is_string($name)) {
|
||||||
if (!is_array($value)) {
|
if (!is_array($value)) {
|
||||||
throw new InvariantViolation(
|
$value = ['name' => $name, 'value' => $value];
|
||||||
"{$this->name}.$name must refer to an associative array with a " .
|
} else {
|
||||||
'"value" key representing an internal value but got: ' . Utils::printSafe($value)
|
$value += ['name' => $name, 'value' => $name];
|
||||||
);
|
|
||||||
}
|
}
|
||||||
$value += ['name' => $name, 'value' => $name];
|
|
||||||
} else if (is_int($name) && is_string($value)) {
|
} else if (is_int($name) && is_string($value)) {
|
||||||
$value = ['name' => $value, 'value' => $value];
|
$value = ['name' => $value, 'value' => $value];
|
||||||
} else {
|
} else {
|
||||||
|
@ -1597,46 +1597,6 @@ class ValidationTest extends \PHPUnit_Framework_TestCase
|
|||||||
$type->assertValid();
|
$type->assertValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @it rejects an Enum type with missing value definition
|
|
||||||
*/
|
|
||||||
public function testRejectsAnEnumTypeWithMissingValueDefinition()
|
|
||||||
{
|
|
||||||
$type = new EnumType([
|
|
||||||
'name' => 'SomeEnum',
|
|
||||||
'values' => [
|
|
||||||
'FOO' => null
|
|
||||||
]
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->setExpectedException(
|
|
||||||
InvariantViolation::class,
|
|
||||||
'SomeEnum.FOO must refer to an associative array with a "value" key representing an internal value but got: null'
|
|
||||||
);
|
|
||||||
|
|
||||||
$type->assertValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @it rejects an Enum type with incorrectly typed value definition
|
|
||||||
*/
|
|
||||||
public function testRejectsAnEnumTypeWithIncorrectlyTypedValueDefinition()
|
|
||||||
{
|
|
||||||
$enumType = new EnumType([
|
|
||||||
'name' => 'SomeEnum',
|
|
||||||
'values' => [
|
|
||||||
'FOO' => 10
|
|
||||||
]
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->setExpectedException(
|
|
||||||
InvariantViolation::class,
|
|
||||||
'SomeEnum.FOO must refer to an associative array with a "value" key representing an internal value but got: 10'
|
|
||||||
);
|
|
||||||
|
|
||||||
$enumType->assertValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @it rejects an Enum type with incorrectly named values
|
* @it rejects an Enum type with incorrectly named values
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user