Skip to content

Commit

Permalink
4708 - add test cases for content stream closing
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernhard Schmitt committed Mar 13, 2024
1 parent a93bdde commit b194763
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@contentrepository @adapters=DoctrineDBAL
Feature: Constraint check test cases for closing content streams

Background:
Given using no content dimensions
And using the following node types:
"""yaml
Neos.ContentRepository:Root: {}
"""
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" |
| newContentStreamId | "cs-identifier" |
And the graph projection is fully up to date

Scenario: Try to close a non-existing content stream:
And the command CloseContentStream is executed with payload and exceptions are caught:
| Key | Value |
| contentStreamId | "i-do-not-exist" |
Then the last command should have thrown an exception of type "ContentStreamDoesNotExistYet"

Scenario: Try to close a content stream that is already closed:
When the command CloseContentStream is executed with payload:
| Key | Value |
| contentStreamId | "cs-identifier" |
And the command CloseContentStream is executed with payload and exceptions are caught:
| Key | Value |
| contentStreamId | "cs-identifier" |
Then the last command should have thrown an exception of type "ContentStreamIsClosed"
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ private function handleCloseContentStream(
): EventsToPublish {
$this->requireContentStreamToExist($command->contentStreamId, $contentRepository);
$expectedVersion = $this->getExpectedVersionOfContentStream($command->contentStreamId, $contentRepository);
$this->requireContentStreamToNotBeClosed($command->contentStreamId, $contentRepository);
$streamName = ContentStreamEventStreamName::fromContentStreamId($command->contentStreamId)->getEventStreamName();

return new EventsToPublish(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ private function handleRebaseWorkspace(
CloseContentStream::create(
$workspace->currentContentStreamId,
)
);
)->block();

// - fork a new content stream
$rebasedContentStreamId = $command->rebasedContentStreamId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,16 @@ public function theCommandCloseContentStreamIsExecutedWithPayload(TableNode $pay

$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
}

/**
* @Given /^the command CloseContentStream is executed with payload and exceptions are caught:$/
*/
public function theCommandCloseContentStreamIsExecutedWithPayloadAndExceptionsAreCaught(TableNode $payloadTable): void
{
try {
$this->theCommandCloseContentStreamIsExecutedWithPayload($payloadTable);
} catch (\Exception $exception) {
$this->lastCommandException = $exception;
}
}
}

0 comments on commit b194763

Please sign in to comment.