mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-22 12:56:05 +03:00
findRemovedTypes test
This commit is contained in:
parent
4207adc098
commit
d9ce567cc8
@ -85,7 +85,7 @@ class FindBreakingChanges
|
|||||||
foreach ($oldTypeMap as $typeName => $typeDefinition) {
|
foreach ($oldTypeMap as $typeName => $typeDefinition) {
|
||||||
if (!isset($newTypeMap[$typeName])) {
|
if (!isset($newTypeMap[$typeName])) {
|
||||||
$breakingChanges[] =
|
$breakingChanges[] =
|
||||||
['type' => self::BREAKING_CHANGE_TYPE_REMOVED, 'description' => "${$typeName} was removed."];
|
['type' => self::BREAKING_CHANGE_TYPE_REMOVED, 'description' => "${typeName} was removed."];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
67
tests/Utils/FindBreakingChangesTest.php
Normal file
67
tests/Utils/FindBreakingChangesTest.php
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* FindBreakingChanges tests
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace GraphQL\Tests\Utils;
|
||||||
|
|
||||||
|
use GraphQL\Type\Definition\ObjectType;
|
||||||
|
use GraphQL\Type\Definition\Type;
|
||||||
|
use GraphQL\Type\Schema;
|
||||||
|
use GraphQL\Utils\FindBreakingChanges;
|
||||||
|
|
||||||
|
class FindBreakingChangesTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
$this->queryType = new ObjectType([
|
||||||
|
'name' => 'Type1',
|
||||||
|
'fields' => [
|
||||||
|
'field1' => [
|
||||||
|
'type' => Type::string()
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testShouldDetectIfTypeWasRemoved()
|
||||||
|
{
|
||||||
|
$type1 = new ObjectType([
|
||||||
|
'name' => 'Type1',
|
||||||
|
'fields' => [
|
||||||
|
'field1' => ['type' => Type::string()],
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
$type2 = new ObjectType([
|
||||||
|
'name' => 'Type2',
|
||||||
|
'fields' => [
|
||||||
|
'field1' => ['type' => Type::string()],
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
$oldSchema = new Schema([
|
||||||
|
'query' => new ObjectType([
|
||||||
|
'name' => 'root',
|
||||||
|
'fields' => [
|
||||||
|
'type1' => $type1,
|
||||||
|
'type2' => $type2
|
||||||
|
]
|
||||||
|
])
|
||||||
|
]);
|
||||||
|
$newSchema = new Schema([
|
||||||
|
'query' => new ObjectType([
|
||||||
|
'name' => 'root',
|
||||||
|
'fields' => [
|
||||||
|
'type2' => $type2
|
||||||
|
]
|
||||||
|
])
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertEquals(['type' => FindBreakingChanges::BREAKING_CHANGE_TYPE_REMOVED, 'description' => 'Type1 was removed.'],
|
||||||
|
FindBreakingChanges::findRemovedTypes($oldSchema, $newSchema)[0]
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals([], FindBreakingChanges::findRemovedTypes($oldSchema, $oldSchema));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user