From 2ef4402c53f8dd89281bdf5c0487f63dba86709c Mon Sep 17 00:00:00 2001
From: Mathias Schreiber <mathias.schreiber@wmdb.de>
Date: Wed, 3 Aug 2016 20:11:30 +0200
Subject: [PATCH] [TASK] Doctrine: Migrate ALL Functional tests of ext:backend

Releases: master
Resolves: #77393
Change-Id: I82fe1e8dc60d6e319f2a16003dc8aa845aeddf01
Reviewed-on: https://review.typo3.org/49362
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Bamboo TYPO3com <info@typo3.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
---
 .../Page/LocalizationControllerTest.php       | 163 ++++++++++++------
 1 file changed, 110 insertions(+), 53 deletions(-)

diff --git a/typo3/sysext/backend/Tests/Functional/Controller/Page/LocalizationControllerTest.php b/typo3/sysext/backend/Tests/Functional/Controller/Page/LocalizationControllerTest.php
index 50b4127982fc..502829db7dbb 100644
--- a/typo3/sysext/backend/Tests/Functional/Controller/Page/LocalizationControllerTest.php
+++ b/typo3/sysext/backend/Tests/Functional/Controller/Page/LocalizationControllerTest.php
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Backend\Tests\Functional\Controller\Page;
 
 use TYPO3\CMS\Backend\Controller\Page\LocalizationController;
 use TYPO3\CMS\Core\Core\Bootstrap;
+use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\DataHandling\DataHandler;
 use TYPO3\CMS\Core\Tests\FunctionalTestCase;
 
@@ -64,25 +65,36 @@ class LocalizationControllerTest extends FunctionalTestCase
 
         $expectedResults = [
             [
-                'pid' => '1',
-                'sys_language_uid' => '1',
-                'l18n_parent' => '1',
+                'pid' => 1,
+                'sys_language_uid' => 1,
+                'l18n_parent' => 1,
                 'header' => '[Translate to Dansk:] Test content 1',
             ],
             [
-                'pid' => '1',
-                'sys_language_uid' => '1',
-                'l18n_parent' => '2',
+                'pid' => 1,
+                'sys_language_uid' => 1,
+                'l18n_parent' => 2,
                 'header' => '[Translate to Dansk:] Test content 2',
             ],
             [
-                'pid' => '1',
-                'sys_language_uid' => '1',
-                'l18n_parent' => '3',
+                'pid' => 1,
+                'sys_language_uid' => 1,
+                'l18n_parent' => 3,
                 'header' => '[Translate to Dansk:] Test content 3',
             ],
         ];
-        $results = $this->getDatabaseConnection()->exec_SELECTgetRows('pid, sys_language_uid, l18n_parent, header', 'tt_content', 'pid = 1 AND sys_language_uid = 1');
+        $queryBuilder = (new ConnectionPool())->getQueryBuilderForTable('tt_content');
+        $queryBuilder->getRestrictions()->removeAll();
+        $results = $queryBuilder
+            ->select('pid', 'sys_language_uid', 'l18n_parent', 'header')
+            ->from('tt_content')
+            ->where(
+                $queryBuilder->expr()->andX(
+                    $queryBuilder->expr()->eq('pid', 1),
+                    $queryBuilder->expr()->eq('sys_language_uid', 1)
+                )
+            )->execute()
+            ->fetchAll();
         $this->assertSame($expectedResults, $results);
     }
 
@@ -104,25 +116,36 @@ class LocalizationControllerTest extends FunctionalTestCase
 
         $expectedResults = [
             [
-                'pid' => '1',
-                'sys_language_uid' => '2',
-                'l18n_parent' => '1',
+                'pid' => 1,
+                'sys_language_uid' => 2,
+                'l18n_parent' => 1,
                 'header' => 'Test indhold 1 (copy 1)',
             ],
             [
-                'pid' => '1',
-                'sys_language_uid' => '2',
-                'l18n_parent' => '2',
+                'pid' => 1,
+                'sys_language_uid' => 2,
+                'l18n_parent' => 2,
                 'header' => 'Test indhold 2 (copy 1)',
             ],
             [
-                'pid' => '1',
-                'sys_language_uid' => '2',
-                'l18n_parent' => '3',
+                'pid' => 1,
+                'sys_language_uid' => 2,
+                'l18n_parent' => 3,
                 'header' => 'Test indhold 3 (copy 1)',
             ],
         ];
-        $results = $this->getDatabaseConnection()->exec_SELECTgetRows('pid, sys_language_uid, l18n_parent, header', 'tt_content', 'pid = 1 AND sys_language_uid = 2');
+        $queryBuilder = (new ConnectionPool())->getQueryBuilderForTable('tt_content');
+        $queryBuilder->getRestrictions()->removeAll();
+        $results = $queryBuilder
+            ->select('pid', 'sys_language_uid', 'l18n_parent', 'header')
+            ->from('tt_content')
+            ->where(
+                $queryBuilder->expr()->andX(
+                    $queryBuilder->expr()->eq('pid', 1),
+                    $queryBuilder->expr()->eq('sys_language_uid', 2)
+                )
+            )->execute()
+            ->fetchAll();
         $this->assertSame($expectedResults, $results);
     }
 
@@ -142,25 +165,36 @@ class LocalizationControllerTest extends FunctionalTestCase
 
         $expectedResults = [
             [
-                'pid' => '1',
-                'sys_language_uid' => '2',
-                'l18n_parent' => '0',
+                'pid' => 1,
+                'sys_language_uid' => 2,
+                'l18n_parent' => 0,
                 'header' => 'Test content 1 (copy 1)',
             ],
             [
-                'pid' => '1',
-                'sys_language_uid' => '2',
-                'l18n_parent' => '0',
+                'pid' => 1,
+                'sys_language_uid' => 2,
+                'l18n_parent' => 0,
                 'header' => 'Test content 2 (copy 1)',
             ],
             [
-                'pid' => '1',
-                'sys_language_uid' => '2',
-                'l18n_parent' => '0',
+                'pid' => 1,
+                'sys_language_uid' => 2,
+                'l18n_parent' => 0,
                 'header' => 'Test content 3 (copy 1)',
             ],
         ];
-        $results = $this->getDatabaseConnection()->exec_SELECTgetRows('pid, sys_language_uid, l18n_parent, header', 'tt_content', 'pid = 1 AND sys_language_uid = 2');
+        $queryBuilder = (new ConnectionPool())->getQueryBuilderForTable('tt_content');
+        $queryBuilder->getRestrictions()->removeAll();
+        $results = $queryBuilder
+            ->select('pid', 'sys_language_uid', 'l18n_parent', 'header')
+            ->from('tt_content')
+            ->where(
+                $queryBuilder->expr()->andX(
+                    $queryBuilder->expr()->eq('pid', 1),
+                    $queryBuilder->expr()->eq('sys_language_uid', 2)
+                )
+            )->execute()
+            ->fetchAll();
         $this->assertSame($expectedResults, $results);
     }
 
@@ -182,25 +216,36 @@ class LocalizationControllerTest extends FunctionalTestCase
 
         $expectedResults = [
             [
-                'pid' => '1',
-                'sys_language_uid' => '2',
-                'l18n_parent' => '0',
+                'pid' => 1,
+                'sys_language_uid' => 2,
+                'l18n_parent' => 0,
                 'header' => 'Test indhold 1 (copy 1)',
             ],
             [
-                'pid' => '1',
-                'sys_language_uid' => '2',
-                'l18n_parent' => '0',
+                'pid' => 1,
+                'sys_language_uid' => 2,
+                'l18n_parent' => 0,
                 'header' => 'Test indhold 2 (copy 1)',
             ],
             [
-                'pid' => '1',
-                'sys_language_uid' => '2',
-                'l18n_parent' => '0',
+                'pid' => 1,
+                'sys_language_uid' => 2,
+                'l18n_parent' => 0,
                 'header' => 'Test indhold 3 (copy 1)',
             ],
         ];
-        $results = $this->getDatabaseConnection()->exec_SELECTgetRows('pid, sys_language_uid, l18n_parent, header', 'tt_content', 'pid = 1 AND sys_language_uid = 2');
+        $queryBuilder = (new ConnectionPool())->getQueryBuilderForTable('tt_content');
+        $queryBuilder->getRestrictions()->removeAll();
+        $results = $queryBuilder
+            ->select('pid', 'sys_language_uid', 'l18n_parent', 'header')
+            ->from('tt_content')
+            ->where(
+                $queryBuilder->expr()->andX(
+                    $queryBuilder->expr()->eq('pid', 1),
+                    $queryBuilder->expr()->eq('sys_language_uid', 2)
+                )
+            )->execute()
+            ->fetchAll();
         $this->assertSame($expectedResults, $results);
     }
 
@@ -246,31 +291,43 @@ class LocalizationControllerTest extends FunctionalTestCase
 
         $expectedResults = [
             [
-                'pid' => '1',
-                'sys_language_uid' => '1',
-                'l18n_parent' => '0',
+                'pid' => 1,
+                'sys_language_uid' => 1,
+                'l18n_parent' => 0,
                 'header' => 'Test content 1 (copy 1)',
             ],
             [
-                'pid' => '1',
-                'sys_language_uid' => '1',
-                'l18n_parent' => '0',
+                'pid' => 1,
+                'sys_language_uid' => 1,
+                'l18n_parent' => 0,
                 'header' => 'Test content 2 (copy 1)',
             ],
             [
-                'pid' => '1',
-                'sys_language_uid' => '1',
-                'l18n_parent' => '0',
+                'pid' => 1,
+                'sys_language_uid' => 1,
+                'l18n_parent' => 0,
                 'header' => 'Test content 2.5 (copy 1)',
             ],
             [
-                'pid' => '1',
-                'sys_language_uid' => '1',
-                'l18n_parent' => '0',
+                'pid' => 1,
+                'sys_language_uid' => 1,
+                'l18n_parent' => 0,
                 'header' => 'Test content 3 (copy 1)',
             ],
         ];
-        $results = $this->getDatabaseConnection()->exec_SELECTgetRows('pid, sys_language_uid, l18n_parent, header', 'tt_content', 'pid = 1 AND sys_language_uid = 1', '', 'sorting ASC');
+        $queryBuilder = (new ConnectionPool())->getQueryBuilderForTable('tt_content');
+        $queryBuilder->getRestrictions()->removeAll();
+        $results = $queryBuilder
+            ->select('pid', 'sys_language_uid', 'l18n_parent', 'header')
+            ->from('tt_content')
+            ->where(
+                $queryBuilder->expr()->andX(
+                    $queryBuilder->expr()->eq('pid', 1),
+                    $queryBuilder->expr()->eq('sys_language_uid', 1)
+                )
+            )->orderBy('sorting', 'ASC')
+            ->execute()
+            ->fetchAll();
         $this->assertSame($expectedResults, $results);
     }
 }
-- 
GitLab