-
-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5384 from dlubitz/feature/90/cleanup-change-proje…
…ction-after-publish FEATURE: Cleanup change projection after publish and discard
- Loading branch information
Showing
35 changed files
with
3,382 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...Features/AssetUsage/W02-WorkspaceDiscarding/01-DiscardWorkspace_WithoutDimensions.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../W02-WorkspaceDiscarding/03-DiscardIndividualNodesFromWorkspace_WithoutDimensions.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...age/W02-WorkspaceDiscarding/04-DiscardIndividualNodesFromWorkspace_WithDimensions.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
Neos.Neos/Tests/Behavior/Features/Bootstrap/ChangeProjectionTrait.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Neos.Neos package. | ||
* | ||
* (c) Contributors of the Neos Project - www.neos.io | ||
* | ||
* This package is Open Source Software. For the full copyright and license | ||
* information, please view the LICENSE file which was distributed with this | ||
* source code. | ||
*/ | ||
|
||
|
||
use Behat\Gherkin\Node\TableNode; | ||
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; | ||
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; | ||
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; | ||
use Neos\Neos\PendingChangesProjection\ChangeFinder; | ||
use PHPUnit\Framework\Assert; | ||
|
||
/** | ||
* Step implementations for tests inside Neos.Neos | ||
* | ||
* @internal only for behat tests within the Neos.Neos package | ||
*/ | ||
trait ChangeProjectionTrait | ||
{ | ||
/** | ||
* @template T of object | ||
* @param class-string<T> $className | ||
* | ||
* @return T | ||
*/ | ||
abstract private function getObject(string $className): object; | ||
|
||
/** | ||
* @Then I expect the ChangeProjection to have the following changes in :contentStreamId: | ||
*/ | ||
public function iExpectTheChangeProjectionToHaveTheFollowingChangesInContentStream(TableNode $table, string $contentStreamId) | ||
{ | ||
$changeFinder = $this->currentContentRepository->projectionState(ChangeFinder::class); | ||
$changes = $changeFinder->findByContentStreamId(ContentStreamId::fromString($contentStreamId)); | ||
|
||
$tableRows = $table->getHash(); | ||
foreach ($changes as $change) { | ||
foreach ($tableRows as $tableRowIndex => $tableRow) { | ||
if (!$change->nodeAggregateId->equals(NodeAggregateId::fromString($tableRow['nodeAggregateId'])) | ||
|| $change->created !== (bool)$tableRow['created'] | ||
|| $change->deleted !== (bool)$tableRow['deleted'] | ||
|| $change->changed !== (bool)$tableRow['changed'] | ||
|| $change->moved !== (bool)$tableRow['moved'] | ||
|| ( | ||
($change->originDimensionSpacePoint === null && strtolower($tableRow['originDimensionSpacePoint']) !== "null") | ||
&& | ||
($change->originDimensionSpacePoint !== null && strtolower($tableRow['originDimensionSpacePoint']) !== "null" && !$change->originDimensionSpacePoint->equals(DimensionSpacePoint::fromJsonString($tableRow['originDimensionSpacePoint']))) | ||
) | ||
) { | ||
continue; | ||
} | ||
unset($tableRows[$tableRowIndex]); | ||
continue 2; | ||
} | ||
} | ||
|
||
if (count($tableRows) !== 0) { | ||
$tableHeader = array_combine(array_values($table->getRow(0)), array_values($table->getRow(0))); | ||
$tableRemain = $tableRows; | ||
array_unshift($tableRemain, $tableHeader); | ||
|
||
Assert::assertEmpty($tableRows, "Not all given changes where found." . PHP_EOL . (new TableNode($tableRemain))->getTableAsString()); | ||
} | ||
Assert::assertSame(count($table->getHash()), $changes->count(), "More changes found as given."); | ||
} | ||
|
||
/** | ||
* @Then I expect the ChangeProjection to have no changes in :contentStreamId | ||
*/ | ||
public function iExpectTheChangeProjectionToHaveNoChangesInContentStream(string $contentStreamId) | ||
{ | ||
$changeFinder = $this->currentContentRepository->projectionState(ChangeFinder::class); | ||
$changes = $changeFinder->findByContentStreamId(ContentStreamId::fromString($contentStreamId)); | ||
|
||
Assert::assertSame(0, $changes->count(), "No changes expected."); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...s/PendingChanges/01-NodeCreation/01-CreateNodeAggregateWithNode_WithoutDimensions.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
@contentrepository @adapters=DoctrineDBAL | ||
@flowEntities | ||
Feature: Create node aggregate with node without dimensions | ||
|
||
Background: | ||
Given using no content dimensions | ||
And using the following node types: | ||
"""yaml | ||
'Neos.ContentRepository.Testing:Node': | ||
properties: | ||
text: | ||
type: string | ||
""" | ||
And using identifier "default", I define a content repository | ||
And I am in content repository "default" | ||
And the command CreateRootWorkspace is executed with payload: | ||
| Key | Value | | ||
| workspaceName | "live" | | ||
| workspaceTitle | "Live" | | ||
| workspaceDescription | "The live workspace" | | ||
| newContentStreamId | "cs-identifier" | | ||
|
||
And I am in workspace "live" | ||
And I am in dimension space point {} | ||
And I am user identified by "initiating-user-identifier" | ||
And the command CreateRootNodeAggregateWithNode is executed with payload: | ||
| Key | Value | | ||
| nodeAggregateId | "lady-eleonode-rootford" | | ||
| nodeTypeName | "Neos.ContentRepository:Root" | | ||
|
||
When the command CreateWorkspace is executed with payload: | ||
| Key | Value | | ||
| workspaceName | "user-workspace" | | ||
| baseWorkspaceName | "live" | | ||
| newContentStreamId | "user-cs-id" | | ||
|
||
Scenario: Nodes on live workspace have been created | ||
Given I am in workspace "live" | ||
|
||
And the following CreateNodeAggregateWithNode commands are executed: | ||
| nodeAggregateId | nodeName | parentNodeAggregateId | nodeTypeName | initialPropertyValues | | ||
| sir-david-nodenborough | node | lady-eleonode-rootford | Neos.ContentRepository.Testing:Node | {} | | ||
| nody-mc-nodeface | child-node | sir-david-nodenborough | Neos.ContentRepository.Testing:Node | {"text": "This is a text about Nody Mc Nodeface"} | | ||
| sir-nodeward-nodington-iii | esquire | lady-eleonode-rootford | Neos.ContentRepository.Testing:Node | {"text": "This is a text about Sir Nodeward Nodington III"} | | ||
|
||
Then I expect the ChangeProjection to have no changes in "cs-identifier" | ||
|
||
|
||
Scenario: Nodes on user workspace have been created | ||
Given I am in workspace "user-workspace" | ||
|
||
And the following CreateNodeAggregateWithNode commands are executed: | ||
| nodeAggregateId | nodeName | parentNodeAggregateId | nodeTypeName | initialPropertyValues | | ||
| sir-david-nodenborough | node | lady-eleonode-rootford | Neos.ContentRepository.Testing:Node | {} | | ||
| nody-mc-nodeface | child-node | sir-david-nodenborough | Neos.ContentRepository.Testing:Node | {"text": "This is a text about Nody Mc Nodeface"} | | ||
| sir-nodeward-nodington-iii | esquire | lady-eleonode-rootford | Neos.ContentRepository.Testing:Node | {"text": "This is a text about Sir Nodeward Nodington III"} | | ||
|
||
Then I expect the ChangeProjection to have the following changes in "user-cs-id": | ||
| nodeAggregateId | created | changed | moved | deleted | originDimensionSpacePoint | | ||
| sir-david-nodenborough | 1 | 1 | 0 | 0 | {} | | ||
| nody-mc-nodeface | 1 | 1 | 0 | 0 | {} | | ||
| sir-nodeward-nodington-iii | 1 | 1 | 0 | 0 | {} | | ||
|
||
And I expect the ChangeProjection to have no changes in "cs-identifier" |
75 changes: 75 additions & 0 deletions
75
...ures/PendingChanges/01-NodeCreation/02-CreateNodeAggregateWithNode_WithDimensions.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
@contentrepository @adapters=DoctrineDBAL | ||
@flowEntities | ||
Feature: Create node aggregate with node with dimensions | ||
|
||
Background: | ||
Given using the following content dimensions: | ||
| Identifier | Values | Generalizations | | ||
| language | de,gsw,fr | gsw->de, fr | | ||
And using the following node types: | ||
"""yaml | ||
'Neos.ContentRepository.Testing:Node': | ||
properties: | ||
text: | ||
type: string | ||
""" | ||
And using identifier "default", I define a content repository | ||
And I am in content repository "default" | ||
And the command CreateRootWorkspace is executed with payload: | ||
| Key | Value | | ||
| workspaceName | "live" | | ||
| workspaceTitle | "Live" | | ||
| workspaceDescription | "The live workspace" | | ||
| newContentStreamId | "cs-identifier" | | ||
|
||
And I am in workspace "live" | ||
And I am in dimension space point {"language": "de"} | ||
And I am user identified by "initiating-user-identifier" | ||
And the command CreateRootNodeAggregateWithNode is executed with payload: | ||
| Key | Value | | ||
| nodeAggregateId | "lady-eleonode-rootford" | | ||
| nodeTypeName | "Neos.ContentRepository:Root" | | ||
|
||
When the command CreateWorkspace is executed with payload: | ||
| Key | Value | | ||
| workspaceName | "user-workspace" | | ||
| baseWorkspaceName | "live" | | ||
| newContentStreamId | "user-cs-id" | | ||
|
||
Scenario: Nodes on live workspace have been created | ||
Given I am in workspace "live" | ||
|
||
And the following CreateNodeAggregateWithNode commands are executed: | ||
| nodeAggregateId | nodeName | parentNodeAggregateId | nodeTypeName | initialPropertyValues | | ||
| sir-david-nodenborough | node | lady-eleonode-rootford | Neos.ContentRepository.Testing:Node | {} | | ||
| nody-mc-nodeface | child-node | sir-david-nodenborough | Neos.ContentRepository.Testing:Node | {"text": "This is a text about Nody Mc Nodeface"} | | ||
|
||
Then I am in dimension space point {"language": "fr"} | ||
And the following CreateNodeAggregateWithNode commands are executed: | ||
| nodeAggregateId | nodeName | parentNodeAggregateId | nodeTypeName | initialPropertyValues | | ||
| sir-nodeward-nodington-iii | esquire | lady-eleonode-rootford | Neos.ContentRepository.Testing:Node | {"text": "This is a french text about Sir Nodeward Nodington III"} | | ||
|
||
Then I expect the ChangeProjection to have no changes in "cs-identifier" | ||
|
||
|
||
Scenario: Nodes on user workspace have been created | ||
Given I am in workspace "user-workspace" | ||
|
||
And the following CreateNodeAggregateWithNode commands are executed: | ||
| nodeAggregateId | nodeName | parentNodeAggregateId | nodeTypeName | initialPropertyValues | | ||
| sir-david-nodenborough | node | lady-eleonode-rootford | Neos.ContentRepository.Testing:Node | {} | | ||
| nody-mc-nodeface | child-node | sir-david-nodenborough | Neos.ContentRepository.Testing:Node | {"text": "This is a text about Nody Mc Nodeface"} | | ||
| sir-nodeward-nodington-iv | bakura | lady-eleonode-rootford | Neos.ContentRepository.Testing:Node | {"text": "This is a text about Sir Nodeward Nodington IV"} | | ||
|
||
Then I am in dimension space point {"language": "fr"} | ||
And the following CreateNodeAggregateWithNode commands are executed: | ||
| nodeAggregateId | nodeName | parentNodeAggregateId | nodeTypeName | initialPropertyValues | | ||
| sir-nodeward-nodington-iii | esquire | lady-eleonode-rootford | Neos.ContentRepository.Testing:Node | {"text": "This is a extended text about Sir Nodeward Nodington III"} | | ||
|
||
Then I expect the ChangeProjection to have the following changes in "user-cs-id": | ||
| nodeAggregateId | created | changed | moved | deleted | originDimensionSpacePoint | | ||
| sir-david-nodenborough | 1 | 1 | 0 | 0 | {"language":"de"} | | ||
| nody-mc-nodeface | 1 | 1 | 0 | 0 | {"language":"de"} | | ||
| sir-nodeward-nodington-iv | 1 | 1 | 0 | 0 | {"language":"de"} | | ||
| sir-nodeward-nodington-iii | 1 | 1 | 0 | 0 | {"language":"fr"} | | ||
And I expect the ChangeProjection to have no changes in "cs-identifier" |
66 changes: 66 additions & 0 deletions
66
...avior/Features/PendingChanges/02-NodeVariation/01-CreateNodeGeneralizationVariant.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
@contentrepository @adapters=DoctrineDBAL | ||
@flowEntities | ||
Feature: Create node generalization variant | ||
|
||
Background: | ||
Given using the following content dimensions: | ||
| Identifier | Values | Generalizations | | ||
| language | de,gsw,fr,en | gsw->de->en, fr | | ||
And using the following node types: | ||
"""yaml | ||
'Neos.ContentRepository.Testing:Node': | ||
properties: | ||
text: | ||
type: string | ||
""" | ||
And using identifier "default", I define a content repository | ||
And I am in content repository "default" | ||
And the command CreateRootWorkspace is executed with payload: | ||
| Key | Value | | ||
| workspaceName | "live" | | ||
| workspaceTitle | "Live" | | ||
| workspaceDescription | "The live workspace" | | ||
| newContentStreamId | "cs-identifier" | | ||
|
||
And I am in workspace "live" | ||
And I am in dimension space point {"language": "de"} | ||
And I am user identified by "initiating-user-identifier" | ||
And the command CreateRootNodeAggregateWithNode is executed with payload: | ||
| Key | Value | | ||
| nodeAggregateId | "lady-eleonode-rootford" | | ||
| nodeTypeName | "Neos.ContentRepository:Root" | | ||
|
||
And the following CreateNodeAggregateWithNode commands are executed: | ||
| nodeAggregateId | nodeName | parentNodeAggregateId | nodeTypeName | initialPropertyValues | | ||
| sir-david-nodenborough | node | lady-eleonode-rootford | Neos.ContentRepository.Testing:Node | {} | | ||
| nody-mc-nodeface | child-node | sir-david-nodenborough | Neos.ContentRepository.Testing:Node | {"text": "This is a text about Nody Mc Nodeface"} | | ||
| sir-nodeward-nodington-iii | esquire | lady-eleonode-rootford | Neos.ContentRepository.Testing:Node | {"text": "This is a text about Sir Nodeward Nodington III"} | | ||
|
||
And the command CreateWorkspace is executed with payload: | ||
| Key | Value | | ||
| workspaceName | "user-workspace" | | ||
| baseWorkspaceName | "live" | | ||
| newContentStreamId | "user-cs-id" | | ||
|
||
Scenario: Create node generalization variant of node with | ||
When I am in workspace "user-workspace" and dimension space point {"language":"de"} | ||
And the command CreateNodeVariant is executed with payload: | ||
| Key | Value | | ||
| nodeAggregateId | "sir-david-nodenborough" | | ||
| sourceOrigin | {"language":"de"} | | ||
| targetOrigin | {"language":"en"} | | ||
|
||
Then I expect the ChangeProjection to have no changes in "cs-identifier" | ||
Then I expect the ChangeProjection to have the following changes in "user-cs-id": | ||
| nodeAggregateId | created | changed | moved | deleted | originDimensionSpacePoint | | ||
| sir-david-nodenborough | 1 | 1 | 0 | 0 | {"language":"en"} | | ||
|
||
And the command PublishWorkspace is executed with payload: | ||
| Key | Value | | ||
| workspaceName | "user-workspace" | | ||
| newContentStreamId | "new-user-workspace-cs-id" | | ||
|
||
Then I expect the ChangeProjection to have no changes in "cs-identifier" | ||
Then I expect the ChangeProjection to have no changes in "user-cs-id" | ||
Then I expect the ChangeProjection to have no changes in "new-user-workspace-cs-id" |
Oops, something went wrong.