[TASK] Add functional tests for discarding created elements 69/27769/2
authorOliver Hader <oliver@typo3.org>
Fri, 21 Feb 2014 11:52:31 +0000 (12:52 +0100)
committerOliver Hader <oliver.hader@typo3.org>
Fri, 21 Feb 2014 12:14:38 +0000 (13:14 +0100)
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
typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/AbstractActionTestCase.php
typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/DataSet/Assertion/createAndCopyContentRecordAndDiscardCopiedContentRecord.csv [new file with mode: 0644]
typo3/sysext/workspaces/Tests/Functional/DataHandling/Regular/DataSet/Assertion/createContentRecordAndDiscardCreatedContentRecord.csv [new file with mode: 0644]

index 1729d45..f950753 100644 (file)
@@ -84,6 +84,37 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
        /**
         * @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
+        */
        public function modifyContentRecord() {
                $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, array('header' => 'Testing #1'));
                $this->assertAssertionDataSet('modifyContentRecord');
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 (file)
index 0000000..4e6f1cf
--- /dev/null
@@ -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 (file)
index 0000000..5d756db
--- /dev/null
@@ -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