Skip to content

Commit

Permalink
TASK: Add test for nodeType property unset behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Oct 15, 2023
1 parent f51830a commit 904f93a
Showing 1 changed file with 88 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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'));
}
}

0 comments on commit 904f93a

Please sign in to comment.