Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: Add test for nodeType property unset behaviour #4620

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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' => []
]
]
Comment on lines +416 to +424
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should discuss at some point if we like this kinda stuff

Copy link
Member

@ahaeslich ahaeslich Oct 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have an issue where this can be discussed?

Copy link
Member Author

@mhsdesign mhsdesign Oct 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

];

$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
Loading