From fe856edefad437062ae26906c1e5f15cd11ea8fb Mon Sep 17 00:00:00 2001 From: Oliver Hader <oliver@typo3.org> Date: Fri, 21 Feb 2014 12:52:31 +0100 Subject: [PATCH] [TASK] Add functional tests for discarding created elements The workspaces API has the command "clearWSID" that reverts elements that have been modified/created/deleted in a workspace. The regular behavior is to keep the elements but mark it as deleted and unset the value in "t3ver_wsid". Resolves: #56179 Releases: 6.2 Change-Id: I55bc72add6f41449dd99f5b6b2816cd1cda3e092 Reviewed-on: https://review.typo3.org/27769 Reviewed-by: Oliver Hader Tested-by: Oliver Hader --- .../Regular/AbstractActionTestCase.php | 31 +++++++++++++++++++ ...entRecordAndDiscardCopiedContentRecord.csv | 8 +++++ ...ntRecordAndDiscardCreatedContentRecord.csv | 6 ++++ 3 files changed, 45 insertions(+) create mode 100644 typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/DataSet/Assertion/createAndCopyContentRecordAndDiscardCopiedContentRecord.csv create mode 100644 typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/DataSet/Assertion/createContentRecordAndDiscardCreatedContentRecord.csv diff --git a/typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/AbstractActionTestCase.php b/typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/AbstractActionTestCase.php index 1729d452c31b..f95075375f2d 100644 --- a/typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/AbstractActionTestCase.php +++ b/typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/AbstractActionTestCase.php @@ -81,6 +81,37 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', array('Testing #1', 'Testing #2')); } + /** + * @test + */ + public function createContentRecordAndDiscardCreatedContentRecord() { + $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1')); + $newContentId = $newTableIds[self::TABLE_Content][0]; + $versionedNewContentId = $this->actionService->getDataHander()->getAutoVersionId(self::TABLE_Content, $newContentId); + $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedNewContentId); + $this->assertAssertionDataSet('createContentRecordAndDiscardCreatedContentRecord'); + + $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent(); + $this->assertResponseContentDoesNotHaveRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1'); + } + + /** + * @test + */ + public function createAndCopyContentRecordAndDiscardCopiedContentRecord() { + $newTableIds = $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1')); + $newContentId = $newTableIds[self::TABLE_Content][0]; + $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $newContentId, self::VALUE_PageId); + $copiedContentId = $copiedTableIds[self::TABLE_Content][$newContentId]; + $versionedCopiedContentId = $this->actionService->getDataHander()->getAutoVersionId(self::TABLE_Content, $copiedContentId); + $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedCopiedContentId); + $this->assertAssertionDataSet('createAndCopyContentRecordAndDiscardCopiedContentRecord'); + + $responseContent = $this->getFrontendResponse(self::VALUE_PageId, 0, self::VALUE_BackendUserId, self::VALUE_WorkspaceId)->getResponseContent(); + $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1'); + $this->assertResponseContentDoesNotHaveRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1 (copy 1)'); + } + /** * @test */ diff --git a/typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/DataSet/Assertion/createAndCopyContentRecordAndDiscardCopiedContentRecord.csv b/typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/DataSet/Assertion/createAndCopyContentRecordAndDiscardCopiedContentRecord.csv new file mode 100644 index 000000000000..4e6f1cfa7e57 --- /dev/null +++ b/typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/DataSet/Assertion/createAndCopyContentRecordAndDiscardCopiedContentRecord.csv @@ -0,0 +1,8 @@ +tt_content +,uid,pid,sorting,deleted,sys_language_uid,l18n_parent,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,header,image,tx_irretutorial_1nff_hotels +,297,89,256,0,0,0,0,0,0,0,0,"Regular Element #1",,0 +,298,89,512,0,0,0,0,0,0,0,0,"Regular Element #2",,0 +,299,89,128,0,0,0,1,1,0,0,0,"Testing #1",,0 +,300,-1,128,0,0,0,1,-1,0,299,0,"Testing #1",,0 +,301,89,1000000000,1,0,0,0,1,0,0,0,"Testing #1 (copy 1)",,0 +,302,-1,1000000000,1,0,0,0,-1,0,301,0,"Testing #1 (copy 1)",0,0 diff --git a/typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/DataSet/Assertion/createContentRecordAndDiscardCreatedContentRecord.csv b/typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/DataSet/Assertion/createContentRecordAndDiscardCreatedContentRecord.csv new file mode 100644 index 000000000000..5d756db8076a --- /dev/null +++ b/typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/DataSet/Assertion/createContentRecordAndDiscardCreatedContentRecord.csv @@ -0,0 +1,6 @@ +tt_content +,uid,pid,sorting,deleted,sys_language_uid,l18n_parent,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,header,image,tx_irretutorial_1nff_hotels +,297,89,256,0,0,0,0,0,0,0,0,"Regular Element #1",,0 +,298,89,512,0,0,0,0,0,0,0,0,"Regular Element #2",,0 +,299,89,1000000000,1,0,0,0,1,0,0,0,"Testing #1",,0 +,300,-1,1000000000,1,0,0,0,-1,0,299,0,"Testing #1",,0 -- GitLab