Skip to content

Commit dbccf9b

Browse files
author
Ben Roberts
committed
testDetectsRemovalOfInterfaces
1 parent 0bb689d commit dbccf9b

File tree

2 files changed

+54
-3
lines changed

2 files changed

+54
-3
lines changed

src/Utils/FindBreakingChanges.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ public static function findInterfacesRemovedFromObjectTypes(
552552
})) {
553553
$oldInterfaceName = $oldInterface->name;
554554
$breakingChanges[] = ['type' => self::BREAKING_CHANGE_INTERFACE_REMOVED_FROM_OBJECT,
555-
'description' => "${typeName} no longer implements interface ${oldInterfaceName}"
555+
'description' => "${typeName} no longer implements interface ${oldInterfaceName}."
556556
];
557557
}
558558
}

tests/Utils/FindBreakingChangesTest.php

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,8 @@ public function testDetectsAdditionOfFieldArg()
862862
FindBreakingChanges::findArgChanges($oldSchema, $newSchema)['breakingChanges'][0]);
863863
}
864864

865-
public function testDoesNotFlagArgsWithSameTypeSignature() {
865+
public function testDoesNotFlagArgsWithSameTypeSignature()
866+
{
866867
$inputType1a = new InputObjectType([
867868
'name' => 'InputType1',
868869
'fields' => [
@@ -923,7 +924,8 @@ public function testDoesNotFlagArgsWithSameTypeSignature() {
923924
$this->assertEquals([], FindBreakingChanges::findArgChanges($oldSchema, $newSchema)['breakingChanges']);
924925
}
925926

926-
public function testArgsThatMoveAwayFromNonNull() {
927+
public function testArgsThatMoveAwayFromNonNull()
928+
{
927929
$oldType = new ObjectType([
928930
'name' => 'Type1',
929931
'fields' => [
@@ -966,4 +968,53 @@ public function testArgsThatMoveAwayFromNonNull() {
966968

967969
$this->assertEquals([], FindBreakingChanges::findArgChanges($oldSchema, $newSchema)['breakingChanges']);
968970
}
971+
972+
public function testDetectsRemovalOfInterfaces()
973+
{
974+
$interface1 = new InterfaceType([
975+
'name' => 'Interface1',
976+
'fields' => [
977+
'field1' => Type::string()
978+
],
979+
'resolveType' => function () {
980+
}
981+
]);
982+
$oldType = new ObjectType([
983+
'name' => 'Type1',
984+
'interfaces' => [$interface1],
985+
'fields' => [
986+
'field1' => Type::string()
987+
]
988+
]);
989+
$newType = new ObjectType([
990+
'name' => 'Type1',
991+
'fields' => [
992+
'field1' => Type::string()
993+
]
994+
]);
995+
996+
$oldSchema = new Schema([
997+
'query' => new ObjectType([
998+
'name' => 'root',
999+
'fields' => [
1000+
'type1' => $oldType,
1001+
]
1002+
])
1003+
]);
1004+
$newSchema = new Schema([
1005+
'query' => new ObjectType([
1006+
'name' => 'root',
1007+
'fields' => [
1008+
'type1' => $newType
1009+
]
1010+
])
1011+
]);
1012+
1013+
$this->assertEquals(
1014+
[
1015+
'type' => FindBreakingChanges::BREAKING_CHANGE_INTERFACE_REMOVED_FROM_OBJECT,
1016+
'description' => 'Type1 no longer implements interface Interface1.'
1017+
],
1018+
FindBreakingChanges::findInterfacesRemovedFromObjectTypes($oldSchema, $newSchema)[0]);
1019+
}
9691020
}

0 commit comments

Comments
 (0)