mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-22 12:56:05 +03:00
findTypesThatChangedKind test
This commit is contained in:
parent
d9ce567cc8
commit
b2b5d6f080
@ -116,7 +116,7 @@ class FindBreakingChanges
|
||||
$newTypeKindName = self::typeKindName($newTypeDefinition);
|
||||
$breakingChanges[] = [
|
||||
'type' => self::BREAKING_CHANGE_TYPE_CHANGED,
|
||||
'description' => "${$typeName} changed from ${oldTypeKindName} to ${newTypeKindName}."
|
||||
'description' => "${typeName} changed from ${oldTypeKindName} to ${newTypeKindName}."
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,10 @@
|
||||
|
||||
namespace GraphQL\Tests\Utils;
|
||||
|
||||
use GraphQL\Type\Definition\InterfaceType;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Type\Definition\UnionType;
|
||||
use GraphQL\Type\Schema;
|
||||
use GraphQL\Utils\FindBreakingChanges;
|
||||
|
||||
@ -64,4 +66,49 @@ class FindBreakingChangesTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals([], FindBreakingChanges::findRemovedTypes($oldSchema, $oldSchema));
|
||||
}
|
||||
|
||||
public function testShouldDetectTypeChanges()
|
||||
{
|
||||
$objectType = new ObjectType([
|
||||
'name' => 'ObjectType',
|
||||
'fields' => [
|
||||
'field1' => ['type' => Type::string()],
|
||||
]
|
||||
]);
|
||||
|
||||
$interfaceType = new InterfaceType([
|
||||
'name' => 'Type1',
|
||||
'fields' => [
|
||||
'field1' => ['type' => Type::string()]
|
||||
]
|
||||
]);
|
||||
|
||||
$unionType = new UnionType([
|
||||
'name' => 'Type1',
|
||||
'types' => [new ObjectType(['name' => 'blah'])],
|
||||
]);
|
||||
|
||||
$oldSchema = new Schema([
|
||||
'query' => new ObjectType([
|
||||
'name' => 'root',
|
||||
'fields' => [
|
||||
'type1' => $interfaceType
|
||||
]
|
||||
])
|
||||
]);
|
||||
|
||||
$newSchema = new Schema([
|
||||
'query' => new ObjectType([
|
||||
'name' => 'root',
|
||||
'fields' => [
|
||||
'type1' => $unionType
|
||||
]
|
||||
])
|
||||
]);
|
||||
|
||||
$this->assertEquals(
|
||||
['type' => FindBreakingChanges::BREAKING_CHANGE_TYPE_CHANGED, 'description' => 'Type1 changed from an Interface type to a Union type.'],
|
||||
FindBreakingChanges::findTypesThatChangedKind($oldSchema, $newSchema)[0]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user