diff --git a/src/Utils/FindBreakingChanges.php b/src/Utils/FindBreakingChanges.php index 7754924..0a8325c 100644 --- a/src/Utils/FindBreakingChanges.php +++ b/src/Utils/FindBreakingChanges.php @@ -552,7 +552,7 @@ class FindBreakingChanges })) { $oldInterfaceName = $oldInterface->name; $breakingChanges[] = ['type' => self::BREAKING_CHANGE_INTERFACE_REMOVED_FROM_OBJECT, - 'description' => "${typeName} no longer implements interface ${oldInterfaceName}" + 'description' => "${typeName} no longer implements interface ${oldInterfaceName}." ]; } } diff --git a/tests/Utils/FindBreakingChangesTest.php b/tests/Utils/FindBreakingChangesTest.php index 0050c38..018e1bd 100644 --- a/tests/Utils/FindBreakingChangesTest.php +++ b/tests/Utils/FindBreakingChangesTest.php @@ -862,7 +862,8 @@ class FindBreakingChangesTest extends \PHPUnit_Framework_TestCase FindBreakingChanges::findArgChanges($oldSchema, $newSchema)['breakingChanges'][0]); } - public function testDoesNotFlagArgsWithSameTypeSignature() { + public function testDoesNotFlagArgsWithSameTypeSignature() + { $inputType1a = new InputObjectType([ 'name' => 'InputType1', 'fields' => [ @@ -923,7 +924,8 @@ class FindBreakingChangesTest extends \PHPUnit_Framework_TestCase $this->assertEquals([], FindBreakingChanges::findArgChanges($oldSchema, $newSchema)['breakingChanges']); } - public function testArgsThatMoveAwayFromNonNull() { + public function testArgsThatMoveAwayFromNonNull() + { $oldType = new ObjectType([ 'name' => 'Type1', 'fields' => [ @@ -966,4 +968,53 @@ class FindBreakingChangesTest extends \PHPUnit_Framework_TestCase $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]); + } } \ No newline at end of file