mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-22 12:56:05 +03:00
testDetectsValuesRemovedFromEnum
This commit is contained in:
parent
98ce1ccc69
commit
cac011246e
@ -479,7 +479,7 @@ class FindBreakingChanges
|
||||
foreach ($oldType->getValues() as $value) {
|
||||
if (!isset($valuesInNewEnum[$value->name])) {
|
||||
$valueName = $value->name;
|
||||
$valuesRemovedFromEnums[] = ['type' => self::BREAKING_CHANGE_VALUE_REMOVED_FROM_ENUM, 'description' => "${valueName} was removed from enum type ${typeName}"];
|
||||
$valuesRemovedFromEnums[] = ['type' => self::BREAKING_CHANGE_VALUE_REMOVED_FROM_ENUM, 'description' => "${valueName} was removed from enum type ${typeName}."];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
namespace GraphQL\Tests\Utils;
|
||||
|
||||
use GraphQL\Type\Definition\EnumType;
|
||||
use GraphQL\Type\Definition\InputObjectType;
|
||||
use GraphQL\Type\Definition\InterfaceType;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
@ -545,4 +546,50 @@ class FindBreakingChangesTest extends \PHPUnit_Framework_TestCase
|
||||
FindBreakingChanges::findTypesRemovedFromUnions($oldSchema, $newSchema)[0]
|
||||
);
|
||||
}
|
||||
|
||||
public function testDetectsValuesRemovedFromEnum()
|
||||
{
|
||||
$oldEnumType = new EnumType([
|
||||
'name' => 'EnumType1',
|
||||
'values' => [
|
||||
'VALUE0' => 0,
|
||||
'VALUE1' => 1,
|
||||
'VALUE2' => 2
|
||||
]
|
||||
]);
|
||||
$newEnumType = new EnumType([
|
||||
'name' => 'EnumType1',
|
||||
'values' => [
|
||||
'VALUE0' => 0,
|
||||
'VALUE2' => 1,
|
||||
'VALUE3' => 2
|
||||
]
|
||||
]);
|
||||
|
||||
$oldSchema = new Schema([
|
||||
'query' => new ObjectType([
|
||||
'name' => 'root',
|
||||
'fields' => [
|
||||
'type1' => $oldEnumType
|
||||
]
|
||||
])
|
||||
]);
|
||||
|
||||
$newSchema = new Schema([
|
||||
'query' => new ObjectType([
|
||||
'name' => 'root',
|
||||
'fields' => [
|
||||
'type1' => $newEnumType
|
||||
]
|
||||
])
|
||||
]);
|
||||
|
||||
$this->assertEquals(
|
||||
[
|
||||
'type' => FindBreakingChanges::BREAKING_CHANGE_VALUE_REMOVED_FROM_ENUM,
|
||||
'description' => 'VALUE1 was removed from enum type EnumType1.'
|
||||
],
|
||||
FindBreakingChanges::findValuesRemovedFromEnums($oldSchema, $newSchema)[0]
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user