Skip to content

Commit

Permalink
TASK: Adjust Legacy migration tests to Neos.Neos:Site
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Sep 29, 2023
1 parent bfccbbf commit b2cd87c
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function __construct(
private readonly Filesystem $files,
private readonly iterable $nodeDataRows,
) {
$this->sitesNodeTypeName = NodeTypeName::forSites();
$this->sitesNodeTypeName = NodeTypeNameFactory::forSites();
$this->contentStreamId = ContentStreamId::create();
$this->visitedNodes = new VisitedNodeAggregates();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ Feature: Export of used Assets, Image Variants and Persistent Resources
And using the following node types:
"""yaml
'unstructured': {}
'Some.Package:SomeNodeType':
'Neos.Neos:Site': {}
'Some.Package:Homepage':
superTypes:
'Neos.Neos:Site': true
properties:
'string':
type: string
Expand Down Expand Up @@ -43,7 +46,7 @@ Feature: Export of used Assets, Image Variants and Persistent Resources
When I have the following node data rows:
| Identifier | Path | Node Type | Properties |
| sites-node-id | /sites | unstructured | |
| site-node-id | /sites/test-site | Some.Package:SomeNodeType | {"string": "asset:\/\/variant1"} |
| site-node-id | /sites/test-site | Some.Package:Homepage | {"string": "asset:\/\/variant1"} |
And I run the asset migration
Then I expect the following Assets to be exported:
"""
Expand Down Expand Up @@ -87,10 +90,10 @@ Feature: Export of used Assets, Image Variants and Persistent Resources
When I have the following node data rows:
| Identifier | Path | Node Type | Dimension Values | Properties |
| sites-node-id | /sites | unstructured | | |
| site-node-id | /sites/test-site | Some.Package:SomeNodeType | | {"string": "asset:\/\/asset1"} |
| site-node-id | /sites/test-site | Some.Package:SomeNodeType | {"language": ["ch"]} | {"image": {"__flow_object_type": "Neos\\Media\\Domain\\Model\\Image", "__identifier": "asset2"}} |
| site-node-id | /sites/test-site | Some.Package:SomeNodeType | {"language": ["en"]} | {"assets": [{"__flow_object_type": "Neos\\Media\\Domain\\Model\\Document", "__identifier": "asset3"}, {"__flow_object_type": "Neos\\Media\\Domain\\Model\\Image", "__identifier": "asset2"}, {"__flow_object_type": "Neos\\Media\\Domain\\Model\\ImageVariant", "__identifier": "variant1"}]} |
| site-node-id | /sites/test-site | Some.Package:SomeNodeType | {"language": ["de"]} | {"string": "some text with an <a href=\"asset:\/\/asset4\">asset link</a>"} |
| site-node-id | /sites/test-site | Some.Package:Homepage | | {"string": "asset:\/\/asset1"} |
| site-node-id | /sites/test-site | Some.Package:Homepage | {"language": ["ch"]} | {"image": {"__flow_object_type": "Neos\\Media\\Domain\\Model\\Image", "__identifier": "asset2"}} |
| site-node-id | /sites/test-site | Some.Package:Homepage | {"language": ["en"]} | {"assets": [{"__flow_object_type": "Neos\\Media\\Domain\\Model\\Document", "__identifier": "asset3"}, {"__flow_object_type": "Neos\\Media\\Domain\\Model\\Image", "__identifier": "asset2"}, {"__flow_object_type": "Neos\\Media\\Domain\\Model\\ImageVariant", "__identifier": "variant1"}]} |
| site-node-id | /sites/test-site | Some.Package:Homepage | {"language": ["de"]} | {"string": "some text with an <a href=\"asset:\/\/asset4\">asset link</a>"} |
And I run the asset migration
Then I expect the following Assets to be exported:
"""
Expand Down Expand Up @@ -178,10 +181,10 @@ Feature: Export of used Assets, Image Variants and Persistent Resources
When I have the following node data rows:
| Identifier | Path | Node Type | Properties |
| sites-node-id | /sites | unstructured | |
| site-node-id | /sites/test-site | Some.Package:SomeNodeType | {"string": "asset:\/\/non-existing-asset"} |
| site-node-id | /sites/test-site | Some.Package:Homepage | {"string": "asset:\/\/non-existing-asset"} |
And I run the asset migration
Then I expect no Assets to be exported
And I expect no ImageVariants to be exported
And I expect no PersistentResources to be exported
And I expect the following errors to be logged
| Failed to extract assets of property "string" of node "site-node-id" (type: "Some.Package:SomeNodeType"): Failed to find mock asset with id "non-existing-asset" |
| Failed to extract assets of property "string" of node "site-node-id" (type: "Some.Package:Homepage"): Failed to find mock asset with id "non-existing-asset" |
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ Feature: Simple migrations without content dimensions
Given using no content dimensions
And using the following node types:
"""yaml
'Some.Package:SomeNodeType':
'unstructured': {}
'Neos.Neos:Site': {}
'Some.Package:Homepage':
superTypes:
'Neos.Neos:Site': true
properties:
'text':
type: string
Expand All @@ -18,9 +22,9 @@ Feature: Simple migrations without content dimensions
When I have the following node data rows:
| Identifier | Path | Node Type | Properties |
| sites-node-id | /sites | unstructured | |
| site-node-id | /sites/test-site | Some.Package:SomeNodeType | {"text": "foo"} |
| site-node-id | /sites/test-site | Some.Package:Homepage | {"text": "foo"} |
And I run the event migration for content stream "cs-id"
Then I expect the following events to be exported
| Type | Payload |
| RootNodeAggregateWithNodeWasCreated | {"contentStreamId": "cs-id", "nodeAggregateId": "sites-node-id", "nodeTypeName": "Neos.Neos:Sites", "nodeAggregateClassification": "root"} |
| NodeAggregateWithNodeWasCreated | {"contentStreamId": "cs-id", "nodeAggregateId": "site-node-id", "nodeTypeName": "Some.Package:SomeNodeType", "nodeName": "test-site", "parentNodeAggregateId": "sites-node-id", "nodeAggregateClassification": "regular", "initialPropertyValues": {"text": {"type": "string", "value": "foo"}}} |
| NodeAggregateWithNodeWasCreated | {"contentStreamId": "cs-id", "nodeAggregateId": "site-node-id", "nodeTypeName": "Some.Package:Homepage", "nodeName": "test-site", "parentNodeAggregateId": "sites-node-id", "nodeAggregateClassification": "regular", "initialPropertyValues": {"text": {"type": "string", "value": "foo"}}} |
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,22 @@ Feature: Exceptional cases during migrations
Given using no content dimensions
And using the following node types:
"""yaml
'unstructured': []
'Some.Package:SomeNodeType':
'unstructured': {}
'Neos.Neos:Site': {}
'Some.Package:Homepage':
superTypes:
'Neos.Neos:Site': true
properties:
'text':
type: string
defaultValue: 'My default text'
'Some.Package:SomeOtherNodeType': []
'Some.Package:SomeNodeType':
properties:
'text':
type: string
'Some.Package:SomeOtherHomepage':
superTypes:
'Neos.Neos:Site': true
"""
And using identifier "default", I define a content repository
And I am in content repository "default"
Expand All @@ -23,44 +32,44 @@ Feature: Exceptional cases during migrations
When I have the following node data rows:
| Identifier | Path | Node Type | Dimension Values |
| sites-node-id | /sites | unstructured | |
| site-node-id | /sites/test-site | Some.Package:SomeNodeType | {"language": ["de"]} |
| site-node-id | /sites/test-site | Some.Package:SomeOtherNodeType | {"language": ["en"]} |
| site-node-id | /sites/test-site | Some.Package:Homepage | {"language": ["de"]} |
| site-node-id | /sites/test-site | Some.Package:SomeOtherHomepage | {"language": ["en"]} |
And I run the event migration
Then I expect a MigrationError with the message
"""
Node aggregate with id "site-node-id" has a type of "Some.Package:SomeOtherNodeType" in content dimension [{"language":"en"}]. I was visited previously for content dimension [{"language":"de"}] with the type "Some.Package:SomeNodeType". Node variants must not have different types
Node aggregate with id "site-node-id" has a type of "Some.Package:SomeOtherHomepage" in content dimension [{"language":"en"}]. I was visited previously for content dimension [{"language":"de"}] with the type "Some.Package:Homepage". Node variants must not have different types
"""

# Note: The behavior was changed with https://github.com/neos/neos-development-collection/pull/4201
Scenario: Node with missing parent
When I have the following node data rows:
| Identifier | Path |
| sites | /sites |
| a | /sites/a |
| c | /sites/b/c |
| Identifier | Path | Node Type |
| sites | /sites | unstructured |
| a | /sites/a | Some.Package:Homepage |
| c | /sites/b/c | unstructured |
And I run the event migration
Then I expect the following events to be exported
| Type | Payload |
| RootNodeAggregateWithNodeWasCreated | {"nodeAggregateId": "sites", "nodeTypeName": "Neos.Neos:Sites", "nodeAggregateClassification": "root"} |
| NodeAggregateWithNodeWasCreated | {"nodeAggregateId": "a", "parentNodeAggregateId": "sites"} |
| NodeAggregateWithNodeWasCreated | {"nodeAggregateId": "a", "nodeTypeName": "Some.Package:Homepage", "parentNodeAggregateId": "sites"} |
And I expect the following errors to be logged
| Failed to find parent node for node with id "c" and dimensions: []. Please ensure that the new content repository has a valid content dimension configuration. Also note that the old CR can sometimes have orphaned nodes. |


# Note: The behavior was changed with https://github.com/neos/neos-development-collection/pull/4201
Scenario: Nodes out of order
When I have the following node data rows:
| Identifier | Path |
| sites | /sites |
| a | /sites/a |
| c | /sites/b/c |
| b | /sites/b |
| Identifier | Path | Node Type |
| sites | /sites | unstructured |
| a | /sites/a | Some.Package:Homepage |
| c | /sites/b/c | unstructured |
| b | /sites/b | Some.Package:Homepage |
And I run the event migration
Then I expect the following events to be exported
| Type | Payload |
| RootNodeAggregateWithNodeWasCreated | {"nodeAggregateId": "sites", "nodeTypeName": "Neos.Neos:Sites", "nodeAggregateClassification": "root"} |
| NodeAggregateWithNodeWasCreated | {"nodeAggregateId": "a", "parentNodeAggregateId": "sites"} |
| NodeAggregateWithNodeWasCreated | {"nodeAggregateId": "b", "parentNodeAggregateId": "sites"} |
| NodeAggregateWithNodeWasCreated | {"nodeAggregateId": "a", "nodeTypeName": "Some.Package:Homepage", "parentNodeAggregateId": "sites"} |
| NodeAggregateWithNodeWasCreated | {"nodeAggregateId": "b", "nodeTypeName": "Some.Package:Homepage", "parentNodeAggregateId": "sites"} |
And I expect the following errors to be logged
| Failed to find parent node for node with id "c" and dimensions: []. Please ensure that the new content repository has a valid content dimension configuration. Also note that the old CR can sometimes have orphaned nodes. |

Expand Down Expand Up @@ -104,11 +113,11 @@ Feature: Exceptional cases during migrations
| Identifier | Default | Values | Generalizations |
| language | en | en, de, ch | ch->de |
When I have the following node data rows:
| Identifier | Path | Dimension Values |
| sites-node-id | /sites | |
| site-node-id | /sites/test-site | {"language": ["de"]} |
| site-node-id | /sites/test-site | {"language": ["ch"]} |
| site-node-id | /sites/test-site | {"language": ["ch"]} |
| Identifier | Path | Node Type | Dimension Values |
| sites-node-id | /sites | unstructured | |
| site-node-id | /sites/test-site | Some.Package:Homepage | {"language": ["de"]} |
| site-node-id | /sites/test-site | Some.Package:Homepage | {"language": ["ch"]} |
| site-node-id | /sites/test-site | Some.Package:Homepage | {"language": ["ch"]} |
And I run the event migration
Then I expect a MigrationError with the message
"""
Expand All @@ -120,10 +129,10 @@ Feature: Exceptional cases during migrations
| Identifier | Default | Values | Generalizations |
| language | en | en, de, ch | ch->de |
When I have the following node data rows:
| Identifier | Path | Dimension Values |
| sites-node-id | /sites | |
| site-node-id | /sites/test-site | {"language": ["de"]} |
| site-node-id | /sites/test-site | {"language": ["de"]} |
| Identifier | Path | Node Type | Dimension Values |
| sites-node-id | /sites | unstructured | |
| site-node-id | /sites/test-site | Some.Package:Homepage | {"language": ["de"]} |
| site-node-id | /sites/test-site | Some.Package:Homepage | {"language": ["de"]} |
And I run the event migration
Then I expect a MigrationError with the message
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ Feature: Migrations that contain nodes with "reference" or "references propertie
Given using no content dimensions
And using the following node types:
"""yaml
'Some.Package:Homepage': []
'unstructured': {}
'Neos.Neos:Site': {}
'Some.Package:Homepage':
superTypes:
'Neos.Neos:Site': true
'Some.Package:SomeNodeType':
properties:
'text':
Expand Down
Loading

0 comments on commit b2cd87c

Please sign in to comment.