diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 391450c..ab22063 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -82,7 +82,7 @@ jobs: cd ${NEOS_BASE_FOLDER} composer require --no-update --no-interaction neos/redirecthandler:"^6.0" composer require --no-update --no-interaction neos/redirecthandler-databasestorage:"^6.0" - + git -C ../${{ env.PACKAGE_FOLDER }} checkout -b build composer config repositories.package '{ "type": "path", "url": "../${{ env.PACKAGE_FOLDER }}", "options": { "symlink": false } }' composer require --no-update --no-interaction neos/redirecthandler-neosadapter:"dev-build as dev-${PACKAGE_TARGET_VERSION}" @@ -94,7 +94,7 @@ jobs: - name: Setup Flow configuration run: | - cd ${NEOS_BASE_FOLDER} + cd ${NEOS_BASE_FOLDER} mkdir -p Configuration/Testing rm -f Configuration/Testing/Settings.yaml cat <> Configuration/Testing/Settings.yaml @@ -109,20 +109,15 @@ jobs: dbname: 'neos_functional_testing' EOF - - name: Setup database schema + - name: Run Behavioral tests run: | cd ${NEOS_BASE_FOLDER} - ./flow doctrine:migrate --quite + # we have to doctrine migrate and setup the cr here as otherwise a transaction error will occur: + # see also https://github.com/neos/neos-development-collection/pull/5005 + FLOW_CONTEXT=Testing ./flow doctrine:migrate --quiet; FLOW_CONTEXT=Testing ./flow cr:setup - - name: Setup CR - run: | - cd ${NEOS_BASE_FOLDER} - ./flow cr:setup - - - name: Run Functional tests - run: | - cd ${NEOS_BASE_FOLDER} - CATCHUPTRIGGER_ENABLE_SYNCHRONOUS_OPTION=1 bin/behat -c Packages/Application/Neos.RedirectHandler.NeosAdapter/Tests/Behavior/behat.yml.dist + cd Packages/Application/Neos.RedirectHandler.NeosAdapter + composer run test:behavioral:stop-on-failure - name: Show log on failure if: ${{ failure() }} diff --git a/Classes/CatchUpHook/DocumentUriPathProjectionHook.php b/Classes/CatchUpHook/DocumentUriPathProjectionHook.php index f03c675..4734cbb 100644 --- a/Classes/CatchUpHook/DocumentUriPathProjectionHook.php +++ b/Classes/CatchUpHook/DocumentUriPathProjectionHook.php @@ -12,13 +12,11 @@ use Neos\RedirectHandler\NeosAdapter\Service\NodeRedirectService; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; use Neos\Neos\FrontendRouting\Projection\DocumentUriPathFinder; -use Neos\ContentRepository\Core\Feature\NodeMove\Dto\CoverageNodeMoveMapping; use Neos\Neos\FrontendRouting\Projection\DocumentNodeInfo; use Neos\Neos\FrontendRouting\Exception\NodeNotFoundException; use Neos\Neos\FrontendRouting\NodeAddress; use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; -use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Neos\FrontendRouting\NodeAddressFactory; final class DocumentUriPathProjectionHook implements CatchUpHookInterface @@ -197,25 +195,21 @@ private function handleNodeWasMoved(NodeAggregateWasMoved $event, \Closure $clos return; } - foreach ($event->nodeMoveMappings as $moveMapping) { - /* @var \Neos\ContentRepository\Core\Feature\NodeMove\Dto\OriginNodeMoveMapping $moveMapping */ - foreach ($moveMapping->newLocations as $newLocation) { - /* @var $newLocation CoverageNodeMoveMapping */ - $node = $this->findNodeByIdAndDimensionSpacePointHash($event->nodeAggregateId, $newLocation->coveredDimensionSpacePoint->hash); - if ($node === null) { - // node probably no document node, skip - continue; - } - - $closure($node, $this->getNodeAddress($event->contentStreamId, $newLocation->coveredDimensionSpacePoint, $node->getNodeAggregateId()), $this->contentRepository->id); - - $descendantsOfNode = $this->getState()->getDescendantsOfNode($node); - array_map(fn (DocumentNodeInfo $descendantOfNode) => $closure( - $descendantOfNode, - $this->getNodeAddress($event->contentStreamId, $newLocation->coveredDimensionSpacePoint, $descendantOfNode->getNodeAggregateId()), - $this->contentRepository->id - ), iterator_to_array($descendantsOfNode)); + foreach ($event->succeedingSiblingsForCoverage as $interdimensionalSibling) { + $node = $this->findNodeByIdAndDimensionSpacePointHash($event->nodeAggregateId, $interdimensionalSibling->dimensionSpacePoint->hash); + if ($node === null) { + // node probably no document node, skip + continue; } + + $closure($node, $this->getNodeAddress($event->contentStreamId, $interdimensionalSibling->dimensionSpacePoint, $node->getNodeAggregateId()), $this->contentRepository->id); + + $descendantsOfNode = $this->getState()->getDescendantsOfNode($node); + array_map(fn (DocumentNodeInfo $descendantOfNode) => $closure( + $descendantOfNode, + $this->getNodeAddress($event->contentStreamId, $interdimensionalSibling->dimensionSpacePoint, $descendantOfNode->getNodeAggregateId()), + $this->contentRepository->id + ), iterator_to_array($descendantsOfNode)); } } diff --git a/Tests/Behavior/Features/Bootstrap/FeatureContext.php b/Tests/Behavior/Features/Bootstrap/FeatureContext.php index 4ce92c5..4ea6d24 100644 --- a/Tests/Behavior/Features/Bootstrap/FeatureContext.php +++ b/Tests/Behavior/Features/Bootstrap/FeatureContext.php @@ -1,59 +1,36 @@ initializeFlow(); - } - $this->objectManager = self::$bootstrap->getObjectManager(); - $this->contentRepositoryRegistry = $this->objectManager->get(ContentRepositoryRegistry::class); - - $this->setupCRTestSuiteTrait(); + self::bootstrapFlow(); + $this->contentRepositoryRegistry = $this->getObject(ContentRepositoryRegistry::class); } protected function getContentRepositoryService( diff --git a/Tests/Behavior/Features/Bootstrap/RedirectOperationTrait.php b/Tests/Behavior/Features/Bootstrap/RedirectOperationTrait.php index cc6c820..77aaa58 100755 --- a/Tests/Behavior/Features/Bootstrap/RedirectOperationTrait.php +++ b/Tests/Behavior/Features/Bootstrap/RedirectOperationTrait.php @@ -17,6 +17,14 @@ trait RedirectOperationTrait { + /** + * @template T of object + * @param class-string $className + * + * @return T + */ + abstract private function getObject(string $className): object; + /** * @Given /^I have the following redirects:$/ * @When /^I create the following redirects:$/ @@ -24,8 +32,8 @@ trait RedirectOperationTrait public function iHaveTheFollowingRedirects($table): void { $rows = $table->getHash(); - $nodeRedirectStorage = $this->objectManager->get(RedirectStorage::class); - $redirectRepository = $this->objectManager->get(RedirectRepository::class); + $nodeRedirectStorage = $this->getObject(RedirectStorage::class); + $redirectRepository = $this->getObject(RedirectRepository::class); foreach ($rows as $row) { $nodeRedirectStorage->addRedirect( @@ -42,7 +50,7 @@ public function iHaveTheFollowingRedirects($table): void */ public function iShouldHaveARedirectWithSourceUriAndTargetUri($sourceUri, $targetUri): void { - $nodeRedirectStorage = $this->objectManager->get(RedirectStorage::class); + $nodeRedirectStorage = $this->getObject(RedirectStorage::class); $redirect = $nodeRedirectStorage->getOneBySourceUriPathAndHost($sourceUri); @@ -62,7 +70,7 @@ public function iShouldHaveARedirectWithSourceUriAndTargetUri($sourceUri, $targe */ public function iShouldHaveARedirectWithSourceUriAndStatus($sourceUri, $statusCode): void { - $nodeRedirectStorage = $this->objectManager->get(RedirectStorage::class); + $nodeRedirectStorage = $this->getObject(RedirectStorage::class); $redirect = $nodeRedirectStorage->getOneBySourceUriPathAndHost($sourceUri); @@ -82,7 +90,7 @@ public function iShouldHaveARedirectWithSourceUriAndStatus($sourceUri, $statusCo */ public function iShouldHaveNoRedirectWithSourceUriAndTargetUri($sourceUri, $targetUri): void { - $nodeRedirectStorage = $this->objectManager->get(RedirectStorage::class); + $nodeRedirectStorage = $this->getObject(RedirectStorage::class); $redirect = $nodeRedirectStorage->getOneBySourceUriPathAndHost($sourceUri); if ($redirect !== null) { @@ -101,7 +109,7 @@ public function iShouldHaveNoRedirectWithSourceUriAndTargetUri($sourceUri, $targ */ public function iShouldHaveNoRedirectWithSourceUri($sourceUri): void { - $nodeRedirectStorage = $this->objectManager->get(RedirectStorage::class); + $nodeRedirectStorage = $this->getObject(RedirectStorage::class); $redirect = $nodeRedirectStorage->getOneBySourceUriPathAndHost($sourceUri); diff --git a/Tests/Behavior/Features/MultipleDimensions.feature b/Tests/Behavior/Features/MultipleDimensions.feature index 8bec5f0..e05f4bb 100644 --- a/Tests/Behavior/Features/MultipleDimensions.feature +++ b/Tests/Behavior/Features/MultipleDimensions.feature @@ -1,4 +1,4 @@ -@fixtures @contentrepository +@flowEntities Feature: Basic redirect handling with document nodes in multiple dimensions Background: @@ -44,12 +44,11 @@ Feature: Basic redirect handling with document nodes in multiple dimensions | Key | Value | | workspaceName | "live" | | newContentStreamId | "cs-identifier" | + And I am in workspace "live" and dimension space point {} And the command CreateRootNodeAggregateWithNode is executed with payload: | Key | Value | | nodeAggregateId | "site-root" | | nodeTypeName | "Neos.Neos:Sites" | - | contentStreamId | "cs-identifier" | - And the graph projection is fully up to date # site-root # behat @@ -59,7 +58,6 @@ Feature: Basic redirect handling with document nodes in multiple dimensions # imprint # buy # mail - And I am in content stream "cs-identifier" and dimension space point {} And the following CreateNodeAggregateWithNode commands are executed: | nodeAggregateId | parentNodeAggregateId | nodeTypeName | initialPropertyValues | originDimensionSpacePoint | nodeName | | behat | site-root | Neos.Neos:Test.Redirect.Page | {"uriPathSegment": "home"} | {"language": "en", "market": "DE"} | node1 | @@ -99,7 +97,6 @@ Feature: Basic redirect handling with document nodes in multiple dimensions DE: DE CH: CH """ - And The documenturipath projection is up to date And the command CreateNodeVariant is executed with payload: | Key | Value | | nodeAggregateId | "behat" | @@ -136,16 +133,13 @@ Feature: Basic redirect handling with document nodes in multiple dimensions | sourceOrigin | {"language":"en", "market": "DE"} | | targetOrigin | {"language":"en", "market": "CH"} | - @fixtures Scenario: Move a node down into different node and a redirect will be created When the command MoveNodeAggregate is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "imprint" | | dimensionSpacePoint | {"language": "en", "market": "DE"} | | newParentNodeAggregateId | "company" | | newSucceedingSiblingNodeAggregateId | null | - And The documenturipath projection is up to date Then I should have a redirect with sourceUri "DE/imprint.html" and targetUri "DE/company/imprint.html" Then I should have a redirect with sourceUri "CH/imprint.html" and targetUri "CH/company/imprint.html" Then I should have a redirect with sourceUri "en_DE/imprint.html" and targetUri "en_DE/company/imprint.html" @@ -153,16 +147,13 @@ Feature: Basic redirect handling with document nodes in multiple dimensions Then I should have a redirect with sourceUri "ch_DE/imprint.html" and targetUri "ch_DE/company/imprint.html" Then I should have a redirect with sourceUri "ch_CH/imprint.html" and targetUri "ch_CH/company/imprint.html" - @fixtures Scenario: Move a node up into different node and a redirect will be created When the command MoveNodeAggregate is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "service" | | dimensionSpacePoint | {"language": "en", "market": "DE"} | | newParentNodeAggregateId | "behat" | | newSucceedingSiblingNodeAggregateId | null | - And The documenturipath projection is up to date Then I should have a redirect with sourceUri "DE/company/service.html" and targetUri "DE/service.html" And I should have a redirect with sourceUri "CH/company/service.html" and targetUri "CH/service.html" @@ -171,15 +162,12 @@ Feature: Basic redirect handling with document nodes in multiple dimensions And I should have a redirect with sourceUri "ch_DE/company/service.html" and targetUri "ch_DE/service.html" And I should have a redirect with sourceUri "ch_CH/company/service.html" and targetUri "ch_CH/service.html" - @fixtures Scenario: Change the the `uriPathSegment` and a redirect will be created When the command SetNodeProperties is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "company" | | originDimensionSpacePoint | {"language": "en", "market": "CH"} | | propertyValues | {"uriPathSegment": "evil-company"} | - And The documenturipath projection is up to date Then I should have a redirect with sourceUri "en_CH/company.html" and targetUri "en_CH/evil-company.html" And I should have a redirect with sourceUri "en_CH/company/service.html" and targetUri "en_CH/evil-company/service.html" @@ -190,21 +178,17 @@ Feature: Basic redirect handling with document nodes in multiple dimensions And I should have no redirect with sourceUri "ch_CH/company.html" And I should have no redirect with sourceUri "ch_DE/company.html" - @fixtures Scenario: Change the the `uriPathSegment` multiple times and multiple redirects will be created When the command SetNodeProperties is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "company" | | originDimensionSpacePoint | {"language": "en", "market": "CH"} | | propertyValues | {"uriPathSegment": "evil-corp"} | And the command SetNodeProperties is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "company" | | originDimensionSpacePoint | {"language": "en", "market": "CH"} | | propertyValues | {"uriPathSegment": "more-evil-corp"} | - And The documenturipath projection is up to date Then I should have a redirect with sourceUri "en_CH/company.html" and targetUri "en_CH/more-evil-corp.html" And I should have a redirect with sourceUri "en_CH/company/service.html" and targetUri "en_CH/more-evil-corp/service.html" @@ -217,74 +201,57 @@ Feature: Basic redirect handling with document nodes in multiple dimensions And I should have no redirect with sourceUri "DE/company.html" And I should have no redirect with sourceUri "en_DE/company.html" - @fixtures Scenario: Retarget an existing redirect when the source URI matches the source URI of the new redirect When I have the following redirects: | sourceuripath | targeturipath | | en_CH/company.html | en_CH/company-old.html | And the command SetNodeProperties is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "company" | | originDimensionSpacePoint | {"language": "en", "market": "CH"} | | propertyValues | {"uriPathSegment": "my-company"} | - And The documenturipath projection is up to date Then I should have a redirect with sourceUri "en_CH/company.html" and targetUri "en_CH/my-company.html" And I should have a redirect with sourceUri "en_CH/company/service.html" and targetUri "en_CH/my-company/service.html" And I should have a redirect with sourceUri "en_CH/company/about.html" and targetUri "en_CH/my-company/about.html" And I should have no redirect with sourceUri "en_CH/company.html" and targetUri "en_CH/company-old.html" - @fixtures Scenario: No redirect should be created for an existing node if any non URI related property changes When the command SetNodeProperties is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "buy" | | originDimensionSpacePoint | {"language": "en", "market": "DE"} | | propertyValues | {"title": "my-buy"} | - And The documenturipath projection is up to date Then I should have no redirect with sourceUri "en_DE/buy.html" - @fixtures Scenario: No redirect should be created for an restricted node by nodetype When the command SetNodeProperties is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "restricted-by-nodetype" | | originDimensionSpacePoint | {"language": "en", "market": "DE"} | | propertyValues | {"uriPathSegment": "restricted-by-nodetype-new"} | - And The documenturipath projection is up to date Then I should have no redirect with sourceUri "en/restricted.html" -# @fixtures -# Scenario: Redirects should be created for a hidden node +## Scenario: Redirects should be created for a hidden node # When the command DisableNodeAggregate is executed with payload: # | Key | Value | -# | contentStreamId | "cs-identifier" | # | nodeAggregateId | "mail" | # | coveredDimensionSpacePoint | {"language": "en", "market": "DE"} | # | nodeVariantSelectionStrategy | "allVariants" | -# And the graph projection is fully up to date # When the command SetNodeProperties is executed with payload: # | Key | Value | -# | contentStreamId | "cs-identifier" | # | nodeAggregateId | "mail" | # | originDimensionSpacePoint | {"language": "en", "market": "DE"} | # | propertyValues | {"uriPathSegment": "not-mail"} | -# And The documenturipath projection is up to date # Then I should have a redirect with sourceUri "en_DE/mail.html" and targetUri "en_DE/not-mail.html" # Then I should have a redirect with sourceUri "en_CH/mail.html" and targetUri "en_CH/not-mail.html" - @fixtures Scenario: Change the the `uriPathSegment` and a redirect will be created also for fallback When the command SetNodeProperties is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "company" | | originDimensionSpacePoint | {"language": "de", "market": "DE"} | | propertyValues | {"uriPathSegment": "evil-company"} | - And The documenturipath projection is up to date Then I should have a redirect with sourceUri "DE/company.html" and targetUri "DE/evil-company.html" And I should have a redirect with sourceUri "DE/company/service.html" and targetUri "DE/evil-company/service.html" @@ -300,16 +267,12 @@ Feature: Basic redirect handling with document nodes in multiple dimensions And I should have no redirect with sourceUri "en_CH/company.html" And I should have no redirect with sourceUri "en_CH/company/service.html" - @fixtures Scenario: A removed node should lead to a GONE response with empty target uri (allSpecializations) Given the command RemoveNodeAggregate is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "company" | | coveredDimensionSpacePoint | {"language": "en", "market": "CH"} | | nodeVariantSelectionStrategy | "allSpecializations" | - And the graph projection is fully up to date - And The documenturipath projection is up to date Then I should have a redirect with sourceUri "en_CH/company.html" and statusCode "410" And I should have a redirect with sourceUri "en_CH/company.html" and targetUri "" @@ -331,16 +294,12 @@ Feature: Basic redirect handling with document nodes in multiple dimensions And I should have no redirect with sourceUri "en_DE/company/service.html" And I should have no redirect with sourceUri "en_DE/company/about.html" - @fixtures Scenario: A removed node should lead to a GONE response with empty target uri (allVariants) Given the command RemoveNodeAggregate is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "company" | | coveredDimensionSpacePoint | {"language": "de", "market": "CH"} | | nodeVariantSelectionStrategy | "allVariants" | - And the graph projection is fully up to date - And The documenturipath projection is up to date Then I should have a redirect with sourceUri "DE/company.html" and statusCode "410" And I should have a redirect with sourceUri "DE/company.html" and targetUri "" @@ -377,16 +336,12 @@ Feature: Basic redirect handling with document nodes in multiple dimensions And I should have a redirect with sourceUri "en_DE/company/about.html" and targetUri "" - @fixtures Scenario: A removed node should lead to a GONE response with empty target uri also for fallback (allSpecializations) Given the command RemoveNodeAggregate is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "company" | | nodeVariantSelectionStrategy | "allSpecializations" | | coveredDimensionSpacePoint | {"language": "de", "market" : "DE"} | - And the graph projection is fully up to date - And The documenturipath projection is up to date Then I should have a redirect with sourceUri "DE/company.html" and statusCode "410" And I should have a redirect with sourceUri "DE/company.html" and targetUri "" diff --git a/Tests/Behavior/Features/OneDimension.feature b/Tests/Behavior/Features/OneDimension.feature index 2c420d0..e5957f4 100644 --- a/Tests/Behavior/Features/OneDimension.feature +++ b/Tests/Behavior/Features/OneDimension.feature @@ -1,4 +1,4 @@ -@fixtures @contentrepository +@flowEntities Feature: Basic redirect handling with document nodes in one dimension Background: @@ -43,12 +43,11 @@ Feature: Basic redirect handling with document nodes in one dimension | Key | Value | | workspaceName | "live" | | newContentStreamId | "cs-identifier" | + And I am in workspace "live" and dimension space point {} And the command CreateRootNodeAggregateWithNode is executed with payload: | Key | Value | | nodeAggregateId | "site-root" | | nodeTypeName | "Neos.Neos:Sites" | - | contentStreamId | "cs-identifier" | - And the graph projection is fully up to date # site-root # behat @@ -58,7 +57,6 @@ Feature: Basic redirect handling with document nodes in one dimension # imprint # buy # mail - And I am in content stream "cs-identifier" and dimension space point {} And the following CreateNodeAggregateWithNode commands are executed: | nodeAggregateId | parentNodeAggregateId | nodeTypeName | initialPropertyValues | originDimensionSpacePoint | nodeName | | behat | site-root | Neos.Neos:Test.Redirect.Page | {"uriPathSegment": "home"} | {"language": "en"} | node1 | @@ -113,45 +111,35 @@ Feature: Basic redirect handling with document nodes in one dimension | nodeAggregateId | "imprint" | | sourceOrigin | {"language":"en"} | | targetOrigin | {"language":"de"} | - And The documenturipath projection is up to date - @fixtures Scenario: Move a node down into different node and a redirect will be created When the command MoveNodeAggregate is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "imprint" | | dimensionSpacePoint | {"language": "en"} | | newParentNodeAggregateId | "company" | | newSucceedingSiblingNodeAggregateId | null | - And The documenturipath projection is up to date - Then I should have a redirect with sourceUri "en/imprint.html" and targetUri "en/company/imprint.html" + Then I should have a redirect with sourceUri "en/imprint.html" and targetUri "en/company/imprint.html" And I should have a redirect with sourceUri "imprint.html" and targetUri "company/imprint.html" And I should have a redirect with sourceUri "ch/imprint.html" and targetUri "ch/company/imprint.html" - @fixtures Scenario: Move a node up into different node and a redirect will be created When the command MoveNodeAggregate is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "service" | | dimensionSpacePoint | {"language": "en"} | | newParentNodeAggregateId | "behat" | | newSucceedingSiblingNodeAggregateId | null | - And The documenturipath projection is up to date - Then I should have a redirect with sourceUri "en/company/service.html" and targetUri "en/service.html" + Then I should have a redirect with sourceUri "en/company/service.html" and targetUri "en/service.html" And I should have a redirect with sourceUri "company/service.html" and targetUri "service.html" And I should have a redirect with sourceUri "ch/company/service.html" and targetUri "ch/service.html" - @fixtures Scenario: Change the the `uriPathSegment` and a redirect will be created When the command SetNodeProperties is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "company" | | originDimensionSpacePoint | {"language": "en"} | | propertyValues | {"uriPathSegment": "evil-corp"} | - And The documenturipath projection is up to date Then I should have a redirect with sourceUri "en/company.html" and targetUri "en/evil-corp.html" And I should have a redirect with sourceUri "en/company/about.html" and targetUri "en/evil-corp/about.html" @@ -166,21 +154,17 @@ Feature: Basic redirect handling with document nodes in one dimension And I should have no redirect with sourceUri "ch/company/service.html" - @fixtures Scenario: Change the the `uriPathSegment` multiple times and multiple redirects will be created When the command SetNodeProperties is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "company" | | originDimensionSpacePoint | {"language": "en"} | | propertyValues | {"uriPathSegment": "evil-corp"} | And the command SetNodeProperties is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "company" | | originDimensionSpacePoint | {"language": "en"} | | propertyValues | {"uriPathSegment": "more-evil-corp"} | - And The documenturipath projection is up to date Then I should have a redirect with sourceUri "en/company.html" and targetUri "en/more-evil-corp.html" And I should have a redirect with sourceUri "en/company/service.html" and targetUri "en/more-evil-corp/service.html" @@ -188,72 +172,55 @@ Feature: Basic redirect handling with document nodes in one dimension And I should have a redirect with sourceUri "en/evil-corp/service.html" and targetUri "en/more-evil-corp/service.html" - @fixtures Scenario: Retarget an existing redirect when the source URI matches the source URI of the new redirect When I have the following redirects: | sourceuripath | targeturipath | | company | company-old | And the command SetNodeProperties is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "company" | | originDimensionSpacePoint | {"language": "en"} | | propertyValues | {"uriPathSegment": "my-company"} | - And The documenturipath projection is up to date - Then I should have a redirect with sourceUri "en/company.html" and targetUri "en/my-company.html" + Then I should have a redirect with sourceUri "en/company.html" and targetUri "en/my-company.html" And I should have no redirect with sourceUri "en/company.html" and targetUri "en/company-old.html" And I should have a redirect with sourceUri "en/company/service.html" and targetUri "en/my-company/service.html" - @fixtures Scenario: No redirect should be created for an existing node if any non URI related property changes When the command SetNodeProperties is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "buy" | | originDimensionSpacePoint | {"language": "en"} | | propertyValues | {"title": "my-buy"} | - And The documenturipath projection is up to date - Then I should have no redirect with sourceUri "en/buy.html" + Then I should have no redirect with sourceUri "en/buy.html" - @fixtures Scenario: No redirect should be created for an restricted node by nodetype When the command SetNodeProperties is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "restricted-by-nodetype" | | originDimensionSpacePoint | {"language": "en"} | | propertyValues | {"uriPathSegment": "restricted-by-nodetype-new"} | - And The documenturipath projection is up to date - Then I should have no redirect with sourceUri "en/restricted.html" + Then I should have no redirect with sourceUri "en/restricted.html" -# @fixtures -# Scenario: Redirects should be created for a hidden node +## Scenario: Redirects should be created for a hidden node # When the command DisableNodeAggregate is executed with payload: # | Key | Value | -# | contentStreamId | "cs-identifier" | # | nodeAggregateId | "mail" | # | coveredDimensionSpacePoint | {"language": "en"} | # | nodeVariantSelectionStrategy | "allVariants" | -# And the graph projection is fully up to date -# When the command SetNodeProperties is executed with payload: +## When the command SetNodeProperties is executed with payload: # | Key | Value | -# | contentStreamId | "cs-identifier" | # | nodeAggregateId | "mail" | # | originDimensionSpacePoint | {"language": "en"} | # | propertyValues | {"uriPathSegment": "not-mail"} | -# And The documenturipath projection is up to date -# Then I should have a redirect with sourceUri "en/mail.html" and targetUri "en/not-mail.html" +# # Then I should have a redirect with sourceUri "en/mail.html" and targetUri "en/not-mail.html" - @fixtures Scenario: Change the the `uriPathSegment` and a redirect will be created also for fallback And the command SetNodeProperties is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "company" | | originDimensionSpacePoint | {"language": "de"} | | propertyValues | {"uriPathSegment": "unternehmen"} | - And The documenturipath projection is up to date Then I should have a redirect with sourceUri "company.html" and targetUri "unternehmen.html" And I should have a redirect with sourceUri "company/service.html" and targetUri "unternehmen/service.html" @@ -261,16 +228,12 @@ Feature: Basic redirect handling with document nodes in one dimension And I should have a redirect with sourceUri "ch/company/service.html" and targetUri "ch/unternehmen/service.html" - @fixtures Scenario: A removed node should lead to a GONE response with empty target uri (allSpecializations) Given the command RemoveNodeAggregate is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "company" | | coveredDimensionSpacePoint | {"language": "en"} | | nodeVariantSelectionStrategy | "allSpecializations" | - And the graph projection is fully up to date - And The documenturipath projection is up to date Then I should have a redirect with sourceUri "en/company.html" and statusCode "410" And I should have a redirect with sourceUri "en/company.html" and targetUri "" @@ -282,16 +245,12 @@ Feature: Basic redirect handling with document nodes in one dimension And I should have no redirect with sourceUri "ch/company.html" And I should have no redirect with sourceUri "ch/company/service.html" - @fixtures Scenario: A removed node should lead to a GONE response with empty target uri (allVariants) Given the command RemoveNodeAggregate is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "company" | | coveredDimensionSpacePoint | {"language": "de"} | | nodeVariantSelectionStrategy | "allVariants" | - And the graph projection is fully up to date - And The documenturipath projection is up to date Then I should have a redirect with sourceUri "en/company.html" and statusCode "410" And I should have a redirect with sourceUri "en/company.html" and targetUri "" @@ -308,16 +267,12 @@ Feature: Basic redirect handling with document nodes in one dimension And I should have a redirect with sourceUri "ch/company/service.html" and statusCode "410" And I should have a redirect with sourceUri "ch/company/service.html" and targetUri "" - @fixtures Scenario: A removed node should lead to a GONE response with empty target uri also for fallback (allSpecializations) Given the command RemoveNodeAggregate is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "company" | | nodeVariantSelectionStrategy | "allSpecializations" | | coveredDimensionSpacePoint | {"language": "de"} | - And the graph projection is fully up to date - And The documenturipath projection is up to date Then I should have a redirect with sourceUri "company.html" and statusCode "410" And I should have a redirect with sourceUri "company.html" and targetUri "" diff --git a/Tests/Behavior/Features/WithoutDimensions.feature b/Tests/Behavior/Features/WithoutDimensions.feature index bfeec77..bfcdfa3 100755 --- a/Tests/Behavior/Features/WithoutDimensions.feature +++ b/Tests/Behavior/Features/WithoutDimensions.feature @@ -1,4 +1,4 @@ -@fixtures @contentrepository +@flowEntities Feature: Basic redirect handling with document nodes without dimensions Background: @@ -43,12 +43,11 @@ Feature: Basic redirect handling with document nodes without dimensions | workspaceTitle | "Live" | | workspaceDescription | "The live workspace" | | newContentStreamId | "cs-identifier" | + And I am in workspace "live" and dimension space point {} And the command CreateRootNodeAggregateWithNode is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "site-root" | | nodeTypeName | "Neos.Neos:Sites" | - And the graph projection is fully up to date # site-root # behat @@ -58,7 +57,6 @@ Feature: Basic redirect handling with document nodes without dimensions # imprint # buy # mail - And I am in content stream "cs-identifier" and dimension space point {} And the following CreateNodeAggregateWithNode commands are executed: | nodeAggregateId | parentNodeAggregateId | nodeTypeName | initialPropertyValues | nodeName | | behat | site-root | Neos.Neos:Test.Redirect.Page | {"uriPathSegment": "home"} | node1 | @@ -82,58 +80,45 @@ Feature: Basic redirect handling with document nodes without dimensions resolver: factoryClassName: Neos\Neos\FrontendRouting\DimensionResolution\Resolver\NoopResolverFactory """ - And The documenturipath projection is up to date - @fixtures Scenario: Move a node down into different node and a redirect will be created When the command MoveNodeAggregate is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "imprint" | | dimensionSpacePoint | {} | | newParentNodeAggregateId | "company" | | newSucceedingSiblingNodeAggregateId | null | - And The documenturipath projection is up to date - Then I should have a redirect with sourceUri "imprint.html" and targetUri "company/imprint.html" + Then I should have a redirect with sourceUri "imprint.html" and targetUri "company/imprint.html" Scenario: Move a node up into different node and a redirect will be created When the command MoveNodeAggregate is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "service" | | dimensionSpacePoint | {} | | newParentNodeAggregateId | "behat" | | newSucceedingSiblingNodeAggregateId | null | - And The documenturipath projection is up to date - Then I should have a redirect with sourceUri "company/service.html" and targetUri "service.html" + Then I should have a redirect with sourceUri "company/service.html" and targetUri "service.html" - @fixtures Scenario: Change the the `uriPathSegment` and a redirect will be created When the command SetNodeProperties is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "company" | | originDimensionSpacePoint | {} | | propertyValues | {"uriPathSegment": "evil-corp"} | - And The documenturipath projection is up to date Then I should have a redirect with sourceUri "company.html" and targetUri "evil-corp.html" And I should have a redirect with sourceUri "company/service.html" and targetUri "evil-corp/service.html" - @fixtures Scenario: Change the the `uriPathSegment` multiple times and multiple redirects will be created When the command SetNodeProperties is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "company" | | originDimensionSpacePoint | {} | | propertyValues | {"uriPathSegment": "evil-corp"} | And the command SetNodeProperties is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "company" | | originDimensionSpacePoint | {} | | propertyValues | {"uriPathSegment": "more-evil-corp"} | - And The documenturipath projection is up to date Then I should have a redirect with sourceUri "company.html" and targetUri "more-evil-corp.html" And I should have a redirect with sourceUri "company/service.html" and targetUri "more-evil-corp/service.html" @@ -141,71 +126,53 @@ Feature: Basic redirect handling with document nodes without dimensions And I should have a redirect with sourceUri "evil-corp/service.html" and targetUri "more-evil-corp/service.html" - @fixtures Scenario: Retarget an existing redirect when the source URI matches the source URI of the new redirect When I have the following redirects: | sourceuripath | targeturipath | | company | company-old | And the command SetNodeProperties is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "company" | | originDimensionSpacePoint | {} | | propertyValues | {"uriPathSegment": "my-company"} | - And The documenturipath projection is up to date - Then I should have a redirect with sourceUri "company.html" and targetUri "my-company.html" + Then I should have a redirect with sourceUri "company.html" and targetUri "my-company.html" And I should have no redirect with sourceUri "company.html" and targetUri "company-old.html" And I should have a redirect with sourceUri "company/service.html" and targetUri "my-company/service.html" - @fixtures Scenario: No redirect should be created for an existing node if any non URI related property changes When the command SetNodeProperties is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "buy" | | originDimensionSpacePoint | {} | | propertyValues | {"title": "my-buy"} | - And The documenturipath projection is up to date - Then I should have no redirect with sourceUri "buy.html" + Then I should have no redirect with sourceUri "buy.html" - @fixtures Scenario: No redirect should be created for an restricted node by nodetype When the command SetNodeProperties is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "restricted-by-nodetype" | | originDimensionSpacePoint | {} | | propertyValues | {"uriPathSegment": "restricted-by-nodetype-new"} | - And The documenturipath projection is up to date - Then I should have no redirect with sourceUri "restricted.html" + Then I should have no redirect with sourceUri "restricted.html" - @fixtures Scenario: Redirects should be created for a hidden node When the command DisableNodeAggregate is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "mail" | | coveredDimensionSpacePoint | {} | | nodeVariantSelectionStrategy | "allVariants" | - And the graph projection is fully up to date When the command SetNodeProperties is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "mail" | | originDimensionSpacePoint | {} | | propertyValues | {"uriPathSegment": "not-mail"} | - And The documenturipath projection is up to date - Then I should have a redirect with sourceUri "mail.html" and targetUri "not-mail.html" + Then I should have a redirect with sourceUri "mail.html" and targetUri "not-mail.html" - @fixtures Scenario: A removed node should lead to a GONE response with empty target uri Given the command RemoveNodeAggregate is executed with payload: | Key | Value | - | contentStreamId | "cs-identifier" | | nodeAggregateId | "company" | | nodeVariantSelectionStrategy | "allVariants" | - And the graph projection is fully up to date - And The documenturipath projection is up to date Then I should have a redirect with sourceUri "company.html" and statusCode "410" And I should have a redirect with sourceUri "company.html" and targetUri "" diff --git a/composer.json b/composer.json index a1bd313..e428b87 100644 --- a/composer.json +++ b/composer.json @@ -9,6 +9,10 @@ "neos/neos": "^9.0", "neos/flow": "^9.0" }, + "scripts": { + "test:behat-cli": "../../../bin/behat -f progress --strict --no-interaction", + "test:behavioral:stop-on-failure": "@test:behat-cli -c Tests/Behavior/behat.yml.dist -vvv --stop-on-failure" + }, "autoload": { "psr-4": { "Neos\\RedirectHandler\\NeosAdapter\\": "Classes"