Skip to content

Commit 7523b84

Browse files
committed
TASK: Add tests for the deactivate workspace feature
1 parent 1d84d2d commit 7523b84

File tree

4 files changed

+172
-1
lines changed

4 files changed

+172
-1
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
@contentrepository @adapters=DoctrineDBAL
2+
Feature: Deactivate/Activate workspace constraints
3+
4+
Background:
5+
Given using no content dimensions
6+
And using the following node types:
7+
"""yaml
8+
'Neos.ContentRepository.Testing:Content':
9+
properties:
10+
text:
11+
type: string
12+
'Neos.ContentRepository.Testing:Document':
13+
childNodes:
14+
child1:
15+
type: 'Neos.ContentRepository.Testing:Content'
16+
child2:
17+
type: 'Neos.ContentRepository.Testing:Content'
18+
"""
19+
And using identifier "default", I define a content repository
20+
And I am in content repository "default"
21+
And the command CreateRootWorkspace is executed with payload:
22+
| Key | Value |
23+
| workspaceName | "live" |
24+
| newContentStreamId | "cs-identifier" |
25+
And I am in workspace "live"
26+
And the command CreateRootNodeAggregateWithNode is executed with payload:
27+
| Key | Value |
28+
| workspaceName | "live" |
29+
| nodeAggregateId | "lady-eleonode-rootford" |
30+
| nodeTypeName | "Neos.ContentRepository:Root" |
31+
32+
And the command CreateWorkspace is executed with payload:
33+
| Key | Value |
34+
| workspaceName | "user-test" |
35+
| baseWorkspaceName | "live" |
36+
| newContentStreamId | "user-cs-identifier" |
37+
38+
Scenario: Deactivating the workspace is not allowed for workspaces with other workspaces depending on it
39+
When the command DeactivateWorkspace is executed with payload and exceptions are caught:
40+
| Key | Value |
41+
| workspaceName | "live" |
42+
43+
Then the last command should have thrown an exception of type "WorkspaceHasWorkspacesDependingOnIt"
44+
45+
Scenario: Activating the workspace is not allowed for active workspaces
46+
When the command ActivateWorkspace is executed with payload and exceptions are caught:
47+
| Key | Value |
48+
| workspaceName | "user-test" |
49+
| newContentStreamId | "new-user-cs-identifier" |
50+
51+
Then the last command should have thrown an exception of type "WorkspaceIsActivated" with code 1766069245 and message:
52+
"""
53+
The workspace "user-test" is activated
54+
"""
55+
56+
Scenario: Deactivating the workspace is not allowed if there are pending changes
57+
When the command CreateNodeAggregateWithNode is executed with payload:
58+
| Key | Value |
59+
| workspaceName | "user-test" |
60+
| nodeAggregateId | "holy-nody" |
61+
| nodeTypeName | "Neos.ContentRepository.Testing:Content" |
62+
| originDimensionSpacePoint | {} |
63+
| parentNodeAggregateId | "lady-eleonode-rootford" |
64+
| initialPropertyValues | {"text": "New node in shared"} |
65+
66+
Given I am in workspace "user-test" and dimension space point {}
67+
Then I expect node aggregate identifier "holy-nody" to lead to node user-cs-identifier;holy-nody;{}
68+
69+
When the command DeactivateWorkspace is executed with payload and exceptions are caught:
70+
| Key | Value |
71+
| workspaceName | "user-test" |
72+
73+
Then the last command should have thrown an exception of type "WorkspaceContainsPublishableChanges"
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
@contentrepository @adapters=DoctrineDBAL
2+
Feature: Deactivate and Activate a Workspace
3+
4+
Background:
5+
Given using no content dimensions
6+
And using the following node types:
7+
"""yaml
8+
'Neos.ContentRepository.Testing:Content':
9+
properties:
10+
text:
11+
type: string
12+
'Neos.ContentRepository.Testing:Document':
13+
childNodes:
14+
child1:
15+
type: 'Neos.ContentRepository.Testing:Content'
16+
child2:
17+
type: 'Neos.ContentRepository.Testing:Content'
18+
"""
19+
And using identifier "default", I define a content repository
20+
And I am in content repository "default"
21+
And the command CreateRootWorkspace is executed with payload:
22+
| Key | Value |
23+
| workspaceName | "live" |
24+
| newContentStreamId | "cs-identifier" |
25+
And I am in workspace "live"
26+
And the command CreateRootNodeAggregateWithNode is executed with payload:
27+
| Key | Value |
28+
| workspaceName | "live" |
29+
| nodeAggregateId | "lady-eleonode-rootford" |
30+
| nodeTypeName | "Neos.ContentRepository:Root" |
31+
When the command CreateNodeAggregateWithNode is executed with payload:
32+
| Key | Value |
33+
| workspaceName | "live" |
34+
| nodeAggregateId | "nody-mc-nodeface" |
35+
| nodeTypeName | "Neos.ContentRepository.Testing:Content" |
36+
| originDimensionSpacePoint | {} |
37+
| parentNodeAggregateId | "lady-eleonode-rootford" |
38+
| initialPropertyValues | {"text": "Original text"} |
39+
40+
And the command CreateWorkspace is executed with payload:
41+
| Key | Value |
42+
| workspaceName | "user-test" |
43+
| baseWorkspaceName | "live" |
44+
| newContentStreamId | "user-cs-identifier" |
45+
46+
Scenario: Deactivating a workspace with no pending changes
47+
When the command DeactivateWorkspace is executed with payload:
48+
| Key | Value |
49+
| workspaceName | "user-test" |
50+
Then workspace user-test has status DEACTIVATED
51+
52+
Scenario: Deactivating an already deactivated Workspace fails
53+
And the command DeactivateWorkspace is executed with payload and exceptions are caught:
54+
| Key | Value |
55+
| workspaceName | "user-test" |
56+
When the command DeactivateWorkspace is executed with payload and exceptions are caught:
57+
| Key | Value |
58+
| workspaceName | "user-test" |
59+
Then the last command should have thrown an exception of type "WorkspaceIsDeactivated" with code 1765977861 and message:
60+
"""
61+
The workspace "user-test" is deactivated
62+
"""
63+
64+
Scenario: Activating a deactivated workspace
65+
When the command DeactivateWorkspace is executed with payload:
66+
| Key | Value |
67+
| workspaceName | "user-test" |
68+
And the command ActivateWorkspace is executed with payload:
69+
| Key | Value |
70+
| workspaceName | "user-test" |
71+
| newContentStreamId | "user-new-cs-identifier" |
72+
Then workspace user-test has status UP_TO_DATE
73+
74+
Given I am in workspace "user-test" and dimension space point {}
75+
Then I expect node aggregate identifier "nody-mc-nodeface" to lead to node user-new-cs-identifier;nody-mc-nodeface;{}
76+

Neos.ContentRepository.Core/Classes/Feature/WorkspaceActivation/Command/ActivateWorkspace.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static function fromArray(array $array): self
4444
{
4545
return new self(
4646
WorkspaceName::fromString($array['workspaceName']),
47-
ContentStreamId::fromString($array['contentStreamId'])
47+
ContentStreamId::fromString($array['newContentStreamId'])
4848
);
4949
}
5050
}

Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/GenericCommandExecutionAndEventPublication.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
use Neos\ContentRepository\Core\Feature\RootNodeCreation\Command\UpdateRootNodeAggregateDimensions;
4545
use Neos\ContentRepository\Core\Feature\SubtreeTagging\Command\TagSubtree;
4646
use Neos\ContentRepository\Core\Feature\SubtreeTagging\Command\UntagSubtree;
47+
use Neos\ContentRepository\Core\Feature\WorkspaceActivation\Command\ActivateWorkspace;
48+
use Neos\ContentRepository\Core\Feature\WorkspaceActivation\Command\DeactivateWorkspace;
4749
use Neos\ContentRepository\Core\Feature\WorkspaceCreation\Command\CreateRootWorkspace;
4850
use Neos\ContentRepository\Core\Feature\WorkspaceCreation\Command\CreateWorkspace;
4951
use Neos\ContentRepository\Core\Feature\WorkspaceModification\Command\ChangeBaseWorkspace;
@@ -312,6 +314,24 @@ public function theCommandRebaseWorkspaceIsExecutedWithPayload(TableNode $payloa
312314
$this->handleCommand(RebaseWorkspace::class, $commandArguments);
313315
}
314316

317+
/**
318+
* @When the command DeactivateWorkspace is executed with payload:
319+
*/
320+
public function theCommandDeactivateWorkspaceIsExecutedWithPayload(TableNode $payloadTable): void
321+
{
322+
$commandArguments = $this->readPayloadTable($payloadTable);
323+
$this->handleCommand(DeactivateWorkspace::class, $commandArguments);
324+
}
325+
326+
/**
327+
* @When the command ActivateWorkspace is executed with payload:
328+
*/
329+
public function theCommandActivateWorkspaceIsExecutedWithPayload(TableNode $payloadTable): void
330+
{
331+
$commandArguments = $this->readPayloadTable($payloadTable);
332+
$this->handleCommand(ActivateWorkspace::class, $commandArguments);
333+
}
334+
315335
/**
316336
* @When the command :shortCommandName is executed with payload and exceptions are caught:
317337
*/
@@ -477,6 +497,8 @@ protected static function resolveShortCommandName(string $shortCommandName): str
477497
CreateRootWorkspace::class,
478498
CreateWorkspace::class,
479499
DeleteWorkspace::class,
500+
ActivateWorkspace::class,
501+
DeactivateWorkspace::class,
480502
DisableNodeAggregate::class,
481503
DiscardIndividualNodesFromWorkspace::class,
482504
DiscardWorkspace::class,

0 commit comments

Comments
 (0)