From 904f93a1af48c2369c31c76dbd2c605d4dfcb1d0 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Sun, 15 Oct 2023 11:13:54 +0200 Subject: [PATCH] TASK: Add test for nodeType property unset behaviour --- .../Unit/NodeType/NodeTypeManagerTest.php | 89 ++++++++++++++++++- 1 file changed, 88 insertions(+), 1 deletion(-) diff --git a/Neos.ContentRepository.Core/Tests/Unit/NodeType/NodeTypeManagerTest.php b/Neos.ContentRepository.Core/Tests/Unit/NodeType/NodeTypeManagerTest.php index 60dfb8741bd..34c4a80ba9b 100644 --- a/Neos.ContentRepository.Core/Tests/Unit/NodeType/NodeTypeManagerTest.php +++ b/Neos.ContentRepository.Core/Tests/Unit/NodeType/NodeTypeManagerTest.php @@ -312,7 +312,6 @@ public function arraySupertypesFormatThrowsException() $this->expectException(NodeConfigurationException::class); $nodeTypesFixture = [ 'Neos.ContentRepository.Testing:Base' => [ - 'final' => true ], 'Neos.ContentRepository.Testing:Sub' => [ 'superTypes' => [0 => 'Neos.ContentRepository.Testing:Base'] @@ -335,4 +334,92 @@ public function getSubNodeTypesWithDifferentIncludeFlagValuesReturnsCorrectValue $subNodeTypes = $this->nodeTypeManager->getSubNodeTypes('Neos.ContentRepository.Testing:ContentObject', false); self::assertArrayNotHasKey('Neos.ContentRepository.Testing:AbstractType', $subNodeTypes); } + + /** + * @test + */ + public function anInheritedNodeTypePropertyCannotBeUnset(): void + { + $nodeTypesFixture = [ + 'Neos.ContentRepository.Testing:Base' => [ + 'properties' => [ + 'foo' => [ + 'type' => 'boolean', + ] + ] + ], + 'Neos.ContentRepository.Testing:Sub' => [ + 'superTypes' => ['Neos.ContentRepository.Testing:Base' => true], + 'properties' => [ + 'foo' => null + ] + ] + ]; + + $this->prepareNodeTypeManager($nodeTypesFixture); + $nodeType = $this->nodeTypeManager->getNodeType('Neos.ContentRepository.Testing:Sub'); + + self::assertSame(['foo' => ['type' => 'boolean']], $nodeType->getProperties()); + } + + /** + * @test + */ + public function allInheritedNodeTypePropertiesCannotBeUnset(): void + { + $nodeTypesFixture = [ + 'Neos.ContentRepository.Testing:Base' => [ + 'properties' => [ + 'foo' => [ + 'type' => 'boolean', + ] + ] + ], + 'Neos.ContentRepository.Testing:Sub' => [ + 'superTypes' => ['Neos.ContentRepository.Testing:Base' => true], + 'properties' => null + ] + ]; + + $this->prepareNodeTypeManager($nodeTypesFixture); + $nodeType = $this->nodeTypeManager->getNodeType('Neos.ContentRepository.Testing:Sub'); + + self::assertSame(['foo' => ['type' => 'boolean']], $nodeType->getProperties()); + } + + /** + * @test + */ + public function anInheritedNodeTypePropertyCannotBeSetToEmptyArray(): void + { + $nodeTypesFixture = [ + 'Neos.ContentRepository.Testing:Base' => [ + 'properties' => [ + 'foo' => [ + 'type' => 'boolean', + 'ui' => [ + 'inspector' => [ + 'group' => 'things' + ] + ] + ] + ] + ], + 'Neos.ContentRepository.Testing:Sub' => [ + 'superTypes' => ['Neos.ContentRepository.Testing:Base' => true], + 'properties' => [ + // Pseudo unset. + // The property will still be existent but looses its type information (falls back to string). + // Also, the property will not show up anymore in the ui as the inspector configuration is gone as well. + 'foo' => [] + ] + ] + ]; + + $this->prepareNodeTypeManager($nodeTypesFixture); + $nodeType = $this->nodeTypeManager->getNodeType('Neos.ContentRepository.Testing:Sub'); + + self::assertSame(['foo' => []], $nodeType->getProperties()); + self::assertSame('string', $nodeType->getPropertyType('foo')); + } }