[BUGFIX] Discard vs. Delete workspace changes in tests 12/27712/3
authorOliver Hader <oliver@typo3.org>
Wed, 19 Feb 2014 10:56:16 +0000 (11:56 +0100)
committerOliver Hader <oliver.hader@typo3.org>
Wed, 19 Feb 2014 11:43:09 +0000 (12:43 +0100)
Discarding workspace changes works with the version command
"clearWSID" which might come down to a "delete" action if the
versioned records have a delete or new placeholder (which is
the case for copied or localized elements).
However, the functional tests need to use the "clearWSID"
instead of the "delete" command.

Resolves: #56111
Releases: 6.2
Change-Id: Id10413048a68abdb5ef05bb6e20e6cb6460f9742
Reviewed-on: https://review.typo3.org/27712
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
typo3/sysext/core/Tests/Functional/DataHandling/Framework/ActionService.php
typo3/sysext/workspaces/Tests/Functional/DataHandling/InlineRelationalRecordEditing/ForeignField/AbstractActionTestCase.php
typo3/sysext/workspaces/Tests/Functional/DataHandling/InlineRelationalRecordEditing/ForeignField/DataSet/Assertion/deleteParentContentRecordAndDiscardDeletedParentRecord.csv [new file with mode: 0644]
typo3/sysext/workspaces/Tests/Functional/DataHandling/InlineRelationalRecordEditing/ForeignField/DataSet/Assertion/modifyParentRecordWithHotelChildRecordAndDiscardAllModifiedRecords.csv
typo3/sysext/workspaces/Tests/Functional/DataHandling/InlineRelationalRecordEditing/ForeignField/DataSet/Assertion/modifyParentRecordWithHotelChildRecordAndDiscardModifiedParentRecord.csv

index a48c800..be94b4b 100644 (file)
@@ -151,9 +151,10 @@ class ActionService {
        /**
         * @param string $tableName
         * @param integer $uid
+        * @return array
         */
        public function deleteRecord($tableName, $uid) {
-               $this->deleteRecords(
+               return $this->deleteRecords(
                        array(
                                $tableName => array($uid),
                        )
@@ -162,6 +163,7 @@ class ActionService {
 
        /**
         * @param array $tableRecordIds
+        * @return array
         */
        public function deleteRecords(array $tableRecordIds) {
                $commandMap = array();
@@ -174,6 +176,38 @@ class ActionService {
                }
                $this->dataHandler->start(array(), $commandMap);
                $this->dataHandler->process_cmdmap();
+               // Deleting workspace records is actually a copy(!)
+               return $this->dataHandler->copyMappingArray;
+       }
+
+       /**
+        * @param string $tableName
+        * @param integer $uid
+        */
+       public function clearWorkspaceRecord($tableName, $uid) {
+               $this->clearWorkspaceRecords(
+                       array(
+                               $tableName => array($uid),
+                       )
+               );
+       }
+
+       /**
+        * @param array $tableRecordIds
+        */
+       public function clearWorkspaceRecords(array $tableRecordIds) {
+               $commandMap = array();
+               foreach ($tableRecordIds as $tableName => $ids) {
+                       foreach ($ids as $uid) {
+                               $commandMap[$tableName][$uid] = array(
+                                       'version' => array(
+                                               'action' => 'clearWSID',
+                                       )
+                               );
+                       }
+               }
+               $this->dataHandler->start(array(), $commandMap);
+               $this->dataHandler->process_cmdmap();
        }
 
        /**
index 4a65c9b..e833f07 100644 (file)
@@ -93,6 +93,16 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
        /**
         * @test
         */
+       public function deleteParentContentRecordAndDiscardDeletedParentRecord() {
+               $newTableIds = $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
+               $versionedDeletedContentId = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
+               $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedDeletedContentId);
+               $this->assertAssertionDataSet('deleteParentContentRecordAndDiscardDeletedParentRecord');
+       }
+
+       /**
+        * @test
+        */
        public function copyParentContentRecord() {
                $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
                $this->assertAssertionDataSet('copyParentContentRecord');
@@ -213,7 +223,8 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
                $newContentId = $newTableIds['tt_content'][0];
                $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $newContentId, self::VALUE_PageId);
                $copiedContentId = $copiedTableIds[self::TABLE_Content][$newContentId];
-               $this->actionService->deleteRecord(self::TABLE_Content, $copiedContentId);
+               $versionedCopiedContentId = $this->actionService->getDataHander()->getAutoVersionId(self::TABLE_Content, $copiedContentId);
+               $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedCopiedContentId);
                $this->assertAssertionDataSet('createAndCopyParentContentRecordWithHotelAndOfferChildRecordsAndDiscardCopiedParentRecord');
        }
 
@@ -252,7 +263,8 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
                $newContentId = $newTableIds[self::TABLE_Content][0];
                $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $newContentId, self::VALUE_LanguageId);
                $localizedContentId = $localizedTableIds[self::TABLE_Content][$newContentId];
-               $this->actionService->deleteRecord(self::TABLE_Content, $localizedContentId);
+               $versionedLocalizedContentId = $this->actionService->getDataHander()->getAutoVersionId(self::TABLE_Content, $localizedContentId);
+               $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $versionedLocalizedContentId);
                $this->assertAssertionDataSet('createAndLocalizeParentContentRecordWithHotelAndOfferChildRecordsAndDiscardLocalizedParentRecord');
        }
 
@@ -297,7 +309,8 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
                                self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, 'tx_irretutorial_hotels' => '3,4'),
                        )
                );
-               $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdFirst);
+               $modifiedContentId = $this->actionService->getDataHander()->getAutoVersionId(self::TABLE_Content, self::VALUE_ContentIdFirst);
+               $this->actionService->clearWorkspaceRecord(self::TABLE_Content, $modifiedContentId);
                $this->assertAssertionDataSet('modifyParentRecordWithHotelChildRecordAndDiscardModifiedParentRecord');
        }
 
@@ -312,10 +325,12 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
                                self::TABLE_Content => array('uid' => self::VALUE_ContentIdFirst, 'tx_irretutorial_hotels' => '3,4'),
                        )
                );
-               $this->actionService->deleteRecords(
+               $modifiedContentId = $this->actionService->getDataHander()->getAutoVersionId(self::TABLE_Content, self::VALUE_ContentIdFirst);
+               $modifiedHotelId = $this->actionService->getDataHander()->getAutoVersionId(self::TABLE_Hotel, 4);
+               $this->actionService->clearWorkspaceRecords(
                                array(
-                                       self::TABLE_Hotel => array(4),
-                                       self::TABLE_Content => array(self::VALUE_ContentIdFirst),
+                                       self::TABLE_Hotel => array($modifiedHotelId),
+                                       self::TABLE_Content => array($modifiedContentId),
                                )
                );
                $this->assertAssertionDataSet('modifyParentRecordWithHotelChildRecordAndDiscardAllModifiedRecords');
diff --git a/typo3/sysext/workspaces/Tests/Functional/DataHandling/InlineRelationalRecordEditing/ForeignField/DataSet/Assertion/deleteParentContentRecordAndDiscardDeletedParentRecord.csv b/typo3/sysext/workspaces/Tests/Functional/DataHandling/InlineRelationalRecordEditing/ForeignField/DataSet/Assertion/deleteParentContentRecordAndDiscardDeletedParentRecord.csv
new file mode 100644 (file)
index 0000000..405ca32
--- /dev/null
@@ -0,0 +1,24 @@
+tt_content
+,uid,pid,sorting,deleted,sys_language_uid,l18n_parent,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,header,image,categories,tx_irretutorial_hotels
+,297,89,256,0,0,0,0,0,0,0,0,"Regular Element #1",,0,2
+,298,89,512,0,0,0,0,0,0,0,0,"Regular Element #2",,0,1
+tx_irretutorial_1nff_hotel
+,uid,pid,sorting,deleted,sys_language_uid,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,title,parentid,parenttable,parentidentifier,offers
+,3,89,1,0,0,0,0,0,0,0,"Hotel #1",297,tt_content,,2
+,4,89,2,0,0,0,0,0,0,0,"Hotel #2",297,tt_content,,1
+,5,89,1,0,0,0,0,0,0,0,"Hotel #1",298,tt_content,,1
+tx_irretutorial_1nff_offer
+,uid,pid,sorting,deleted,sys_language_uid,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,title,parentid,parenttable,parentidentifier,prices
+,5,89,1,0,0,0,0,0,0,0,"Offer #1.1",3,tx_irretutorial_1nff_hotel,,3
+,6,89,2,0,0,0,0,0,0,0,"Offer #1.2",3,tx_irretutorial_1nff_hotel,,2
+,7,89,1,0,0,0,0,0,0,0,"Offer #2.1",4,tx_irretutorial_1nff_hotel,,1
+,8,89,1,0,0,0,0,0,0,0,"Offer #1.1",5,tx_irretutorial_1nff_hotel,,1
+tx_irretutorial_1nff_price
+,uid,pid,sorting,deleted,sys_language_uid,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,title,parentid,parenttable,parentidentifier
+,7,89,1,0,0,0,0,0,0,0,"Price #1.1.1",5,tx_irretutorial_1nff_offer,
+,8,89,2,0,0,0,0,0,0,0,"Price #1.1.2",5,tx_irretutorial_1nff_offer,
+,9,89,3,0,0,0,0,0,0,0,"Price #1.1.3",5,tx_irretutorial_1nff_offer,
+,10,89,1,0,0,0,0,0,0,0,"Price #1.2.1",6,tx_irretutorial_1nff_offer,
+,11,89,2,0,0,0,0,0,0,0,"Price #1.2.2",6,tx_irretutorial_1nff_offer,
+,12,89,1,0,0,0,0,0,0,0,"Price #2.1.1",7,tx_irretutorial_1nff_offer,
+,13,89,1,0,0,0,0,0,0,0,"Price #1.1.1",8,tx_irretutorial_1nff_offer,
index 99b1a00..04f8f66 100644 (file)
@@ -2,13 +2,13 @@ tt_content
 ,uid,pid,sorting,deleted,sys_language_uid,l18n_parent,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,header,image,categories,tx_irretutorial_hotels
 ,297,89,256,0,0,0,0,0,0,0,0,"Regular Element #1",,0,2
 ,298,89,512,0,0,0,0,0,0,0,0,"Regular Element #2",,0,1
-,299,-1,256,0,0,0,1,2,0,297,0,"Regular Element #1",0,0,2
+,299,-1,256,0,0,0,0,0,0,297,0,"Regular Element #1",0,0,2
 tx_irretutorial_1nff_hotel
 ,uid,pid,sorting,deleted,sys_language_uid,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,title,parentid,parenttable,parentidentifier,offers
 ,3,89,1,0,0,0,0,0,0,0,"Hotel #1",297,tt_content,,2
 ,4,89,2,0,0,0,0,0,0,0,"Hotel #2",297,tt_content,,1
 ,5,89,1,0,0,0,0,0,0,0,"Hotel #1",298,tt_content,,1
-,6,-1,2,0,0,1,2,0,4,0,"Testing #1",299,tt_content,,1
+,6,-1,2,0,0,0,0,0,4,0,"Testing #1",299,tt_content,,1
 ,7,-1,1,0,0,1,0,0,3,0,"Hotel #1",299,tt_content,,2
 tx_irretutorial_1nff_offer
 ,uid,pid,sorting,deleted,sys_language_uid,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,title,parentid,parenttable,parentidentifier,prices
index f2128db..af7494f 100644 (file)
@@ -2,7 +2,7 @@ tt_content
 ,uid,pid,sorting,deleted,sys_language_uid,l18n_parent,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,header,image,categories,tx_irretutorial_hotels
 ,297,89,256,0,0,0,0,0,0,0,0,"Regular Element #1",,0,2
 ,298,89,512,0,0,0,0,0,0,0,0,"Regular Element #2",,0,1
-,299,-1,256,0,0,0,1,2,0,297,0,"Regular Element #1",0,0,2
+,299,-1,256,0,0,0,0,0,0,297,0,"Regular Element #1",0,0,2
 tx_irretutorial_1nff_hotel
 ,uid,pid,sorting,deleted,sys_language_uid,t3ver_wsid,t3ver_state,t3ver_stage,t3ver_oid,t3ver_move_id,title,parentid,parenttable,parentidentifier,offers
 ,3,89,1,0,0,0,0,0,0,0,"Hotel #1",297,tt_content,,2