From 3c16bc4d7eba1617708a0b4fbdcce3d113060a70 Mon Sep 17 00:00:00 2001
From: Anja Leichsenring <aleichsenring@ab-softlab.de>
Date: Mon, 15 Nov 2021 15:16:48 +0100
Subject: [PATCH] [TASK] Extract relevant parts of JsonRenderer into
 ext:test_irre_csv
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

To further separate concerns from ext:irre_tutorial, the configuration
of JsonRenderer looses all parts that only concern the 1ncsv scenario.

Ext:test_irre_csv receives a dedicated JsonRenderer, that is used by
related test scenarios.

Resolves: #95982
Releases: master
Change-Id: Id83fbbd0133b56c6d1069b385298d6db56fd7142
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72180
Tested-by: core-ci <typo3@b13.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../IRRE/CSV/AbstractActionTestCase.php       |   2 +-
 .../TypoScript/JsonRenderer.typoscript        | 142 ++++++++++++++++++
 .../Fixtures/Frontend/JsonRenderer.typoscript |  61 +-------
 3 files changed, 144 insertions(+), 61 deletions(-)
 create mode 100644 typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_irre_csv/Configuration/TypoScript/JsonRenderer.typoscript

diff --git a/typo3/sysext/core/Tests/Functional/DataHandling/IRRE/CSV/AbstractActionTestCase.php b/typo3/sysext/core/Tests/Functional/DataHandling/IRRE/CSV/AbstractActionTestCase.php
index bfc6936ca6c7..e7e998e5da5b 100644
--- a/typo3/sysext/core/Tests/Functional/DataHandling/IRRE/CSV/AbstractActionTestCase.php
+++ b/typo3/sysext/core/Tests/Functional/DataHandling/IRRE/CSV/AbstractActionTestCase.php
@@ -62,7 +62,7 @@ abstract class AbstractActionTestCase extends AbstractDataHandlerActionTestCase
         $this->importScenarioDataSet('ImportDefault');
 
         $this->setUpFrontendSite(1, $this->siteLanguageConfiguration);
-        $this->setUpFrontendRootPage(1, ['typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.typoscript']);
+        $this->setUpFrontendRootPage(1, ['typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_irre_csv/Configuration/TypoScript/JsonRenderer.typoscript']);
     }
 
     /**
diff --git a/typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_irre_csv/Configuration/TypoScript/JsonRenderer.typoscript b/typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_irre_csv/Configuration/TypoScript/JsonRenderer.typoscript
new file mode 100644
index 000000000000..262c19f3552a
--- /dev/null
+++ b/typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_irre_csv/Configuration/TypoScript/JsonRenderer.typoscript
@@ -0,0 +1,142 @@
+config {
+    no_cache = 1
+    debug = 0
+    admPanel = 0
+    disableAllHeaderCode = 1
+    sendCacheHeaders = 0
+    additionalHeaders.10.header = Content-Type: application/json; charset=utf-8
+    additionalHeaders.10.replace = 1
+
+    watcher {
+        tableFields {
+            pages = uid,_PAGES_OVERLAY_UID,pid,sorting,title,tx_testirrecsv_hotels
+            tt_content = uid,_ORIG_uid,_LOCALIZED_UID,pid,sorting,sys_language_uid,header
+            tx_testirrecsv_hotel = uid,_ORIG_uid,_LOCALIZED_UID,pid,sorting,sys_language_uid,title,offers
+            tx_testirrecsv_offer = uid,_ORIG_uid,_LOCALIZED_UID,pid,sorting,sys_language_uid,title,prices
+            tx_testirrecsv_price = uid,_ORIG_uid,_LOCALIZED_UID,pid,sorting,sys_language_uid,title,price
+        }
+    }
+}
+
+lib.watcherDataObject = COA
+lib.watcherDataObject {
+    1 = LOAD_REGISTER
+    1.watcher.dataWrap = |
+    2 = USER
+    2.userFunc = TYPO3\TestingFramework\Core\Functional\Framework\Frontend\Collector->addRecordData
+    99 = RESTORE_REGISTER
+}
+
+page = PAGE
+page {
+    10 = COA
+    10 {
+        1 = LOAD_REGISTER
+        1.watcher.dataWrap = pages:{field:uid}
+        2 = USER
+        2.userFunc = TYPO3\TestingFramework\Core\Functional\Framework\Frontend\Collector->addRecordData
+        10 = CONTENT
+        10 {
+            stdWrap.required = 1
+            table = pages
+            select {
+                orderBy = sorting
+                pidInList = this
+                # prevent sys_language_uid lookup
+                languageField = 0
+            }
+            renderObj < lib.watcherDataObject
+            renderObj.1.watcher.dataWrap = {register:watcher}|.__pages/pages:{field:uid}
+        }
+        16 = CONTENT
+        16 {
+            if.isTrue.field = tx_testirrecsv_hotels
+            table = tx_testirrecsv_hotel
+            select {
+                uidInList.data = field:tx_testirrecsv_hotels
+                orderBy = sorting
+                # prevent sys_language_uid lookup
+                languageField = 0
+            }
+            renderObj < lib.watcherDataObject
+            renderObj.1.watcher.dataWrap = {register:watcher}|.tx_testirrecsv_hotels/tx_testirrecsv_hotel:{field:uid}
+        }
+        20 = CONTENT
+        20 {
+            table = tt_content
+            select {
+                orderBy = sorting
+                where = {#colPos}=0
+            }
+            renderObj < lib.watcherDataObject
+            renderObj.1.watcher.dataWrap = {register:watcher}|.__contents/tt_content:{field:uid}
+            renderObj {
+                30 = CONTENT
+                30 {
+                    if.isTrue.field = tx_testirrecsv_hotels
+                    table = tx_testirrecsv_hotel
+                    select {
+                        uidInList.data = field:tx_testirrecsv_hotels
+                        orderBy = sorting
+                        # prevent sys_language_uid lookup
+                        languageField = 0
+                    }
+                    renderObj < lib.watcherDataObject
+                    renderObj.1.watcher.dataWrap = {register:watcher}|.tx_testirrecsv_hotels/tx_testirrecsv_hotel:{field:uid}
+                    renderObj {
+                        10 = CONTENT
+                        10 {
+                            if.isTrue.field = offers
+                            table = tx_testirrecsv_offer
+                            select {
+                                uidInList.data = field:offers
+                                orderBy = sorting
+                                # prevent sys_language_uid lookup
+                                languageField = 0
+                            }
+                            renderObj < lib.watcherDataObject
+                            renderObj.1.watcher.dataWrap = {register:watcher}|.offers/tx_testirrecsv_offer:{field:uid}
+                            renderObj {
+                                10 = CONTENT
+                                10 {
+                                    if.isTrue.field = prices
+                                    table = tx_testirrecsv_price
+                                    select {
+                                        uidInList.data = field:prices
+                                        orderBy = sorting
+                                        # prevent sys_language_uid lookup
+                                        languageField = 0
+                                    }
+                                    renderObj < lib.watcherDataObject
+                                    renderObj.1.watcher.dataWrap = {register:watcher}|.prices/tx_testirrecsv_price:{field:uid}
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        stdWrap.postUserFunc = TYPO3\TestingFramework\Core\Functional\Framework\Frontend\Collector->attachSection
+        stdWrap.postUserFunc.as = Default
+    }
+    99999 = COA
+    99999 {
+        stdWrap.postUserFunc = TYPO3\TestingFramework\Core\Functional\Framework\Frontend\Renderer->renderValues
+        stdWrap.postUserFunc.values {
+            page.children {
+                uid.data = page:uid
+                pid.data = page:pid
+                title.data = page:title
+            }
+            languageInfo.children {
+                id.data = context:language:id
+                contentId.data = context:language:contentId
+                fallbackType.data = sitelanguage:fallbackType
+                fallbackChain.data = context:language:fallbackChain
+                overlayType.data = context:language:overlayType
+            }
+        }
+        stdWrap.postUserFunc.as = Scope
+    }
+    stdWrap.postUserFunc = TYPO3\TestingFramework\Core\Functional\Framework\Frontend\Renderer->renderSections
+}
diff --git a/typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.typoscript b/typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.typoscript
index d5e2356e615d..8157180ca4cd 100644
--- a/typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.typoscript
+++ b/typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.typoscript
@@ -9,7 +9,7 @@ config {
 
 	watcher {
 		tableFields {
-			pages = uid,_PAGES_OVERLAY_UID,pid,sorting,title,tx_irretutorial_hotels,tx_testirrecsv_hotels
+			pages = uid,_PAGES_OVERLAY_UID,pid,sorting,title,tx_irretutorial_hotels
 			sys_category = uid,_ORIG_uid,_LOCALIZED_UID,pid,sys_language_uid,title,parent,items,sys_language_uid
 			sys_file = uid,_ORIG_uid,_LOCALIZED_UID,pid,title,sys_language_uid
 			sys_file_reference = uid,_ORIG_uid,_LOCALIZED_UID,title,description,alternative,link,missing,identifier,file,pid,sys_language_uid,title,parent,items,sys_language_uid,uid_local,uid_foreign,tablenames,fieldname,table_local
@@ -17,9 +17,6 @@ config {
 			tx_irretutorial_1nff_hotel = uid,_ORIG_uid,_LOCALIZED_UID,pid,sorting,sys_language_uid,title,offers
 			tx_irretutorial_1nff_offer = uid,_ORIG_uid,_LOCALIZED_UID,pid,sorting,sys_language_uid,title,prices
 			tx_irretutorial_1nff_price = uid,_ORIG_uid,_LOCALIZED_UID,pid,sorting,sys_language_uid,title,price
-			tx_testirrecsv_hotel = uid,_ORIG_uid,_LOCALIZED_UID,pid,sorting,sys_language_uid,title,offers
-			tx_testirrecsv_offer = uid,_ORIG_uid,_LOCALIZED_UID,pid,sorting,sys_language_uid,title,prices
-			tx_testirrecsv_price = uid,_ORIG_uid,_LOCALIZED_UID,pid,sorting,sys_language_uid,title,price
 			tx_testdatahandler_element = uid,_ORIG_uid,_LOCALIZED_UID,pid,sorting,sys_language_uid,title
 		}
 	}
@@ -77,19 +74,6 @@ page {
 			renderObj < lib.watcherDataObject
 			renderObj.1.watcher.dataWrap = {register:watcher}|.tx_irretutorial_hotels/tx_irretutorial_1nff_hotel:{field:uid}
 		}
-		16 = CONTENT
-		16 {
-			if.isTrue.field = tx_testirrecsv_hotels
-			table = tx_testirrecsv_hotel
-			select {
-				uidInList.data = field:tx_testirrecsv_hotels
-				orderBy = sorting
-				# prevent sys_language_uid lookup
-				languageField = 0
-			}
-			renderObj < lib.watcherDataObject
-			renderObj.1.watcher.dataWrap = {register:watcher}|.tx_testirrecsv_hotels/tx_testirrecsv_hotel:{field:uid}
-		}
 		20 = CONTENT
 		20 {
 			table = tt_content
@@ -160,49 +144,6 @@ page {
 						}
 					}
 				}
-				30 = CONTENT
-				30 {
-					if.isTrue.field = tx_testirrecsv_hotels
-					table = tx_testirrecsv_hotel
-					select {
-						uidInList.data = field:tx_testirrecsv_hotels
-						orderBy = sorting
-						# prevent sys_language_uid lookup
-						languageField = 0
-					}
-					renderObj < lib.watcherDataObject
-					renderObj.1.watcher.dataWrap = {register:watcher}|.tx_testirrecsv_hotels/tx_testirrecsv_hotel:{field:uid}
-					renderObj {
-						10 = CONTENT
-						10 {
-							if.isTrue.field = offers
-							table = tx_testirrecsv_offer
-							select {
-								uidInList.data = field:offers
-								orderBy = sorting
-								# prevent sys_language_uid lookup
-								languageField = 0
-							}
-							renderObj < lib.watcherDataObject
-							renderObj.1.watcher.dataWrap = {register:watcher}|.offers/tx_testirrecsv_offer:{field:uid}
-							renderObj {
-								10 = CONTENT
-								10 {
-									if.isTrue.field = prices
-									table = tx_testirrecsv_price
-									select {
-										uidInList.data = field:prices
-										orderBy = sorting
-										# prevent sys_language_uid lookup
-										languageField = 0
-									}
-									renderObj < lib.watcherDataObject
-									renderObj.1.watcher.dataWrap = {register:watcher}|.prices/tx_testirrecsv_price:{field:uid}
-								}
-							}
-						}
-					}
-				}
 				40 = FILES
 				40 {
 					if.isTrue.field = image
-- 
GitLab