diff --git a/src/Utils/FindBreakingChanges.php b/src/Utils/FindBreakingChanges.php index 0894f0c..7864508 100644 --- a/src/Utils/FindBreakingChanges.php +++ b/src/Utils/FindBreakingChanges.php @@ -85,7 +85,7 @@ class FindBreakingChanges foreach ($oldTypeMap as $typeName => $typeDefinition) { if (!isset($newTypeMap[$typeName])) { $breakingChanges[] = - ['type' => self::BREAKING_CHANGE_TYPE_REMOVED, 'description' => "${$typeName} was removed."]; + ['type' => self::BREAKING_CHANGE_TYPE_REMOVED, 'description' => "${typeName} was removed."]; } } diff --git a/tests/Utils/FindBreakingChangesTest.php b/tests/Utils/FindBreakingChangesTest.php new file mode 100644 index 0000000..cb0c220 --- /dev/null +++ b/tests/Utils/FindBreakingChangesTest.php @@ -0,0 +1,67 @@ +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)); + } + +} \ No newline at end of file