Added test for enums with null values

This commit is contained in:
Vladimir Razuvaev 2017-07-04 16:27:40 +07:00
parent 189877c173
commit 1c41fb27ed

View File

@ -253,6 +253,41 @@ class DefinitionTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(true, $value->isDeprecated()); $this->assertEquals(true, $value->isDeprecated());
} }
/**
* @it defines an enum type with a value of `null`
*/
public function testDefinesAnEnumTypeWithAValueOfNullAndUndefined()
{
$EnumTypeWithNullishValue = new EnumType([
'name' => 'EnumWithNullishValue',
'values' => [
'NULL' => ['value' => null],
'UNDEFINED' => ['value' => null],
]
]);
$expected = [
[
'name' => 'NULL',
'description' => null,
'deprecationReason' => null,
'value' => null,
],
[
'name' => 'UNDEFINED',
'description' => null,
'deprecationReason' => null,
'value' => null,
],
];
$actual = $EnumTypeWithNullishValue->getValues();
$this->assertEquals(count($expected), count($actual));
$this->assertEquals($expected[0], (array)$actual[0]);
$this->assertEquals($expected[1], (array)$actual[1]);
}
/** /**
* @it defines an object type with deprecated field * @it defines an object type with deprecated field
*/ */