testDetectsRemovalOfInterfaces

This commit is contained in:
Ben Roberts 2017-11-20 14:39:06 -05:00
parent 0bb689d340
commit dbccf9b196
2 changed files with 54 additions and 3 deletions

View File

@ -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}."
]; ];
} }
} }

View File

@ -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]);
}
} }