[TASK] Enable DataHandler frontend rendering tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Functional / DataHandling / InlineRelationalRecordEditing / ForeignField / AbstractActionTestCase.php
index 50ce71d..373ebb2 100644 (file)
@@ -52,6 +52,8 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
                parent::setUp();
                $this->importScenarioDataSet('LiveDefaultPages');
                $this->importScenarioDataSet('LiveDefaultElements');
+
+               $this->setUpFrontendRootPage(1, array('typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts'));
        }
 
        /**
@@ -64,6 +66,9 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
        public function createParentContentRecord() {
                $this->actionService->createNewRecord(self::TABLE_Content, self::VALUE_PageId, array('header' => 'Testing #1'));
                $this->assertAssertionDataSet('createParentContentRecord');
+
+               $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
+               $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
        }
 
        /**
@@ -72,6 +77,13 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
        public function modifyParentContentRecord() {
                $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, array('header' => 'Testing #1'));
                $this->assertAssertionDataSet('modifyParentContentRecord');
+
+               $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
+               $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
+               $this->assertResponseContentStructureHasRecords(
+                       $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, 'tx_irretutorial_hotels',
+                       self::TABLE_Hotel, 'title', array('Hotel #1')
+               );
        }
 
        /**
@@ -80,14 +92,24 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
        public function deleteParentContentRecord() {
                $this->actionService->deleteRecord(self::TABLE_Content, self::VALUE_ContentIdLast);
                $this->assertAssertionDataSet('deleteParentContentRecord');
+
+               $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
+               $this->assertResponseContentDoesNotHaveRecords($responseContent, self::TABLE_Content, 'header', 'Regular Element #2');
        }
 
        /**
         * @test
         */
        public function copyParentContentRecord() {
-               $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
+               $newTableIds = $this->actionService->copyRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageId);
                $this->assertAssertionDataSet('copyParentContentRecord');
+
+               $newContentId = $newTableIds[self::TABLE_Content][self::VALUE_ContentIdLast];
+               $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
+               $this->assertResponseContentStructureHasRecords(
+                       $responseContent, self::TABLE_Content . ':' . $newContentId, 'tx_irretutorial_hotels',
+                       self::TABLE_Hotel, 'title', array('Hotel #1')
+               );
        }
 
        /**
@@ -96,6 +118,12 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
        public function localizeParentContentRecord() {
                $this->actionService->localizeRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_LanguageId);
                $this->assertAssertionDataSet('localizeParentContentRecord');
+
+               $responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseContent();
+               $this->assertResponseContentStructureHasRecords(
+                       $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, 'tx_irretutorial_hotels',
+                       self::TABLE_Hotel, 'title', array('[Translate to Dansk:] Hotel #1')
+               );
        }
 
        /**
@@ -104,6 +132,16 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
        public function changeParentContentRecordSorting() {
                $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
                $this->assertAssertionDataSet('changeParentContentRecordSorting');
+
+               $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
+               $this->assertResponseContentStructureHasRecords(
+                       $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'tx_irretutorial_hotels',
+                       self::TABLE_Hotel, 'title', array('Hotel #1', 'Hotel #2')
+               );
+               $this->assertResponseContentStructureHasRecords(
+                       $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, 'tx_irretutorial_hotels',
+                       self::TABLE_Hotel, 'title', array('Hotel #1')
+               );
        }
 
        /**
@@ -112,6 +150,13 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
        public function moveParentContentRecordToDifferentPage() {
                $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
                $this->assertAssertionDataSet('moveParentContentRecordToDifferentPage');
+
+               $responseContent = $this->getFrontendResponse(self::VALUE_PageIdTarget)->getResponseContent();
+               $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Regular Element #2');
+               $this->assertResponseContentStructureHasRecords(
+                       $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, 'tx_irretutorial_hotels',
+                       self::TABLE_Hotel, 'title', array('Hotel #1')
+               );
        }
 
        /**
@@ -121,6 +166,17 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
                $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdLast, self::VALUE_PageIdTarget);
                $this->actionService->moveRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, -self::VALUE_ContentIdLast);
                $this->assertAssertionDataSet('moveParentContentRecordToDifferentPageAndChangeSorting');
+
+               $responseContent = $this->getFrontendResponse(self::VALUE_PageIdTarget)->getResponseContent();
+               $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', array('Regular Element #2', 'Regular Element #1'));
+               $this->assertResponseContentStructureHasRecords(
+                       $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'tx_irretutorial_hotels',
+                       self::TABLE_Hotel, 'title', array('Hotel #1', 'Hotel #2')
+               );
+               $this->assertResponseContentStructureHasRecords(
+                       $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, 'tx_irretutorial_hotels',
+                       self::TABLE_Hotel, 'title', array('Hotel #1')
+               );
        }
 
        /**
@@ -133,6 +189,9 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
        public function modifyPageRecord() {
                $this->actionService->modifyRecord(self::TABLE_Page, self::VALUE_PageId, array('title' => 'Testing #1'));
                $this->assertAssertionDataSet('modifyPageRecord');
+
+               $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
+               $this->assertResponseContentHasRecords($responseContent, self::TABLE_Page, 'title', 'Testing #1');
        }
 
        /**
@@ -141,14 +200,21 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
        public function deletePageRecord() {
                $this->actionService->deleteRecord(self::TABLE_Page, self::VALUE_PageId);
                $this->assertAssertionDataSet('deletePageRecord');
+
+               $response = $this->getFrontendResponse(self::VALUE_PageId, 0, 0, 0, FALSE);
+               $this->assertContains('PageNotFoundException', $response->getError());
        }
 
        /**
         * @test
         */
        public function copyPageRecord() {
-               $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
+               $newTableIds = $this->actionService->copyRecord(self::TABLE_Page, self::VALUE_PageId, self::VALUE_PageIdTarget);
                $this->assertAssertionDataSet('copyPageRecord');
+
+               $newPageId = $newTableIds[self::TABLE_Page][self::VALUE_PageId];
+               $responseContent = $this->getFrontendResponse($newPageId)->getResponseContent();
+               $this->assertResponseContentHasRecords($responseContent, self::TABLE_Hotel, 'title', array('Hotel #1', 'Hotel #2', 'Hotel #1'));
        }
 
        /**
@@ -159,7 +225,7 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
         * @test
         */
        public function createParentContentRecordWithHotelAndOfferChildRecords() {
-               $this->actionService->createNewRecords(
+               $newTableIds = $this->actionService->createNewRecords(
                        self::VALUE_PageId,
                        array(
                                self::TABLE_Offer => array('title' => 'Offer #1'),
@@ -168,6 +234,14 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
                        )
                );
                $this->assertAssertionDataSet('createParentContentRecordWithHotelAndOfferChildRecords');
+
+               $newContentId = $newTableIds[self::TABLE_Content][0];
+               $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
+               $this->assertResponseContentHasRecords($responseContent, self::TABLE_Content, 'header', 'Testing #1');
+               $this->assertResponseContentStructureHasRecords(
+                       $responseContent, self::TABLE_Content . ':' . $newContentId, 'tx_irretutorial_hotels',
+                       self::TABLE_Hotel, 'title', 'Hotel #1'
+               );
        }
 
        /**
@@ -186,6 +260,22 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
                $newHotelId = $newTableIds[self::TABLE_Hotel][0];
                $copiedTableIds = $this->actionService->copyRecord(self::TABLE_Content, $newContentId, self::VALUE_PageId);
                $this->assertAssertionDataSet('createAndCopyParentContentRecordWithHotelAndOfferChildRecords');
+
+               $copiedContentId = $copiedTableIds[self::TABLE_Content][$newContentId];
+               $copiedHotelId = $copiedTableIds[self::TABLE_Hotel][$newHotelId];
+               $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
+               $this->assertResponseContentStructureHasRecords(
+                       $responseContent, self::TABLE_Content . ':' . $newContentId, 'tx_irretutorial_hotels',
+                       self::TABLE_Hotel, 'title', 'Hotel #1'
+               );
+               $this->assertResponseContentStructureHasRecords(
+                       $responseContent, self::TABLE_Content . ':' . $copiedContentId, 'tx_irretutorial_hotels',
+                       self::TABLE_Hotel, 'title', 'Hotel #1'
+               );
+               $this->assertResponseContentStructureHasRecords(
+                       $responseContent, self::TABLE_Hotel . ':' . $copiedHotelId, 'offers',
+                       self::TABLE_Offer, 'title', 'Offer #1'
+               );
        }
 
        /**
@@ -205,6 +295,22 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
                $newHotelId = $newTableIds[self::TABLE_Hotel][0];
                $localizedTableIds = $this->actionService->localizeRecord(self::TABLE_Content, $newContentId, self::VALUE_LanguageId);
                $this->assertAssertionDataSet('createAndLocalizeParentContentRecordWithHotelAndOfferChildRecords');
+
+               $localizedContentId = $localizedTableIds[self::TABLE_Content][$newContentId];
+               $localizedHotelId = $localizedTableIds[self::TABLE_Hotel][$newHotelId];
+               $responseContent = $this->getFrontendResponse(self::VALUE_PageId, self::VALUE_LanguageId)->getResponseContent();
+
+               // @todo Does not work since children don't point to live-default record
+               /*
+                       $this->assertResponseContentStructureHasRecords(
+                               $responseContent, self::TABLE_Content . ':' . $localizedContentId, 'tx_irretutorial_hotels',
+                               self::TABLE_Hotel, 'title', '[Translate to Dansk:] Hotel #1'
+                       );
+                       $this->assertResponseContentStructureHasRecords(
+                               $responseContent, self::TABLE_Hotel . ':' . $localizedHotelId, 'offers',
+                               self::TABLE_Offer, 'title', '[Translate to Dansk:] Offer #1'
+                       );
+               */
        }
 
        /**
@@ -213,6 +319,12 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
        public function modifyOnlyHotelChildRecord() {
                $this->actionService->modifyRecord(self::TABLE_Hotel, 4, array('title' => 'Testing #1'));
                $this->assertAssertionDataSet('modifyOnlyHotelChildRecord');
+
+               $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
+               $this->assertResponseContentStructureHasRecords(
+                       $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'tx_irretutorial_hotels',
+                       self::TABLE_Hotel, 'title', array('Hotel #1', 'Testing #1')
+               );
        }
 
        /**
@@ -221,6 +333,12 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
        public function modifyParentRecordAndChangeHotelChildRecordsSorting() {
                $this->actionService->modifyRecord(self::TABLE_Content, self::VALUE_ContentIdFirst, array('tx_irretutorial_hotels' => '4,3'));
                $this->assertAssertionDataSet('modifyParentRecordAndChangeHotelChildRecordsSorting');
+
+               $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
+               $this->assertResponseContentStructureHasRecords(
+                       $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'tx_irretutorial_hotels',
+                       self::TABLE_Hotel, 'title', array('Hotel #2', 'Hotel #1')
+               );
        }
 
        /**
@@ -235,6 +353,12 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
                        )
                );
                $this->assertAssertionDataSet('modifyParentRecordWithHotelChildRecord');
+
+               $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
+               $this->assertResponseContentStructureHasRecords(
+                       $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdFirst, 'tx_irretutorial_hotels',
+                       self::TABLE_Hotel, 'title', array('Hotel #1', 'Testing #1')
+               );
        }
 
        /**
@@ -249,6 +373,12 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
                        )
                );
                $this->assertAssertionDataSet('modifyParentRecordAndAddHotelChildRecord');
+
+               $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
+               $this->assertResponseContentStructureHasRecords(
+                       $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, 'tx_irretutorial_hotels',
+                       self::TABLE_Hotel, 'title', array('Hotel #1', 'Hotel #2')
+               );
        }
 
        /**
@@ -262,6 +392,16 @@ abstract class AbstractActionTestCase extends \TYPO3\CMS\Core\Tests\Functional\D
                        array(self::TABLE_Hotel => array(4))
                );
                $this->assertAssertionDataSet('modifyParentRecordAndDeleteHotelChildRecord');
+
+               $responseContent = $this->getFrontendResponse(self::VALUE_PageId)->getResponseContent();
+               $this->assertResponseContentStructureHasRecords(
+                       $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, 'tx_irretutorial_hotels',
+                       self::TABLE_Hotel, 'title', 'Hotel #1'
+               );
+               $this->assertResponseContentStructureDoesNotHaveRecords(
+                       $responseContent, self::TABLE_Content . ':' . self::VALUE_ContentIdLast, 'tx_irretutorial_hotels',
+                       self::TABLE_Hotel, 'title', 'Hotel #2'
+               );
        }
 
 }