mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-22 12:56:05 +03:00
testDetectsRemovalOfInterfaces
This commit is contained in:
parent
0bb689d340
commit
dbccf9b196
@ -552,7 +552,7 @@ class FindBreakingChanges
|
|||||||
})) {
|
})) {
|
||||||
$oldInterfaceName = $oldInterface->name;
|
$oldInterfaceName = $oldInterface->name;
|
||||||
$breakingChanges[] = ['type' => self::BREAKING_CHANGE_INTERFACE_REMOVED_FROM_OBJECT,
|
$breakingChanges[] = ['type' => self::BREAKING_CHANGE_INTERFACE_REMOVED_FROM_OBJECT,
|
||||||
'description' => "${typeName} no longer implements interface ${oldInterfaceName}"
|
'description' => "${typeName} no longer implements interface ${oldInterfaceName}."
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -862,7 +862,8 @@ class FindBreakingChangesTest extends \PHPUnit_Framework_TestCase
|
|||||||
FindBreakingChanges::findArgChanges($oldSchema, $newSchema)['breakingChanges'][0]);
|
FindBreakingChanges::findArgChanges($oldSchema, $newSchema)['breakingChanges'][0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDoesNotFlagArgsWithSameTypeSignature() {
|
public function testDoesNotFlagArgsWithSameTypeSignature()
|
||||||
|
{
|
||||||
$inputType1a = new InputObjectType([
|
$inputType1a = new InputObjectType([
|
||||||
'name' => 'InputType1',
|
'name' => 'InputType1',
|
||||||
'fields' => [
|
'fields' => [
|
||||||
@ -923,7 +924,8 @@ class FindBreakingChangesTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals([], FindBreakingChanges::findArgChanges($oldSchema, $newSchema)['breakingChanges']);
|
$this->assertEquals([], FindBreakingChanges::findArgChanges($oldSchema, $newSchema)['breakingChanges']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testArgsThatMoveAwayFromNonNull() {
|
public function testArgsThatMoveAwayFromNonNull()
|
||||||
|
{
|
||||||
$oldType = new ObjectType([
|
$oldType = new ObjectType([
|
||||||
'name' => 'Type1',
|
'name' => 'Type1',
|
||||||
'fields' => [
|
'fields' => [
|
||||||
@ -966,4 +968,53 @@ class FindBreakingChangesTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$this->assertEquals([], FindBreakingChanges::findArgChanges($oldSchema, $newSchema)['breakingChanges']);
|
$this->assertEquals([], FindBreakingChanges::findArgChanges($oldSchema, $newSchema)['breakingChanges']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDetectsRemovalOfInterfaces()
|
||||||
|
{
|
||||||
|
$interface1 = new InterfaceType([
|
||||||
|
'name' => 'Interface1',
|
||||||
|
'fields' => [
|
||||||
|
'field1' => Type::string()
|
||||||
|
],
|
||||||
|
'resolveType' => function () {
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
$oldType = new ObjectType([
|
||||||
|
'name' => 'Type1',
|
||||||
|
'interfaces' => [$interface1],
|
||||||
|
'fields' => [
|
||||||
|
'field1' => Type::string()
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
$newType = new ObjectType([
|
||||||
|
'name' => 'Type1',
|
||||||
|
'fields' => [
|
||||||
|
'field1' => Type::string()
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
$oldSchema = new Schema([
|
||||||
|
'query' => new ObjectType([
|
||||||
|
'name' => 'root',
|
||||||
|
'fields' => [
|
||||||
|
'type1' => $oldType,
|
||||||
|
]
|
||||||
|
])
|
||||||
|
]);
|
||||||
|
$newSchema = new Schema([
|
||||||
|
'query' => new ObjectType([
|
||||||
|
'name' => 'root',
|
||||||
|
'fields' => [
|
||||||
|
'type1' => $newType
|
||||||
|
]
|
||||||
|
])
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
[
|
||||||
|
'type' => FindBreakingChanges::BREAKING_CHANGE_INTERFACE_REMOVED_FROM_OBJECT,
|
||||||
|
'description' => 'Type1 no longer implements interface Interface1.'
|
||||||
|
],
|
||||||
|
FindBreakingChanges::findInterfacesRemovedFromObjectTypes($oldSchema, $newSchema)[0]);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user