Skip to content

Commit

Permalink
Merge pull request #4620 from neos/task/addTestForNodeTypePropertyUns…
Browse files Browse the repository at this point in the history
…etBehaviour

TASK: Add test for nodeType property unset behaviour
  • Loading branch information
mhsdesign authored Nov 10, 2023
2 parents 6788cd4 + 05c8150 commit dcc9174
Showing 1 changed file with 88 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,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 @@ -344,6 +343,94 @@ public function getSubNodeTypesWithDifferentIncludeFlagValuesReturnsCorrectValue
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'));
}

/**
* @test
*/
Expand Down

0 comments on commit dcc9174

Please sign in to comment.