From f78b2b28f873d91b99f8513c8f8fc400c5507f98 Mon Sep 17 00:00:00 2001
From: Oliver Eglseder <oliver.eglseder@in2code.de>
Date: Sun, 1 Nov 2015 15:51:43 +0100
Subject: [PATCH] =?UTF-8?q?[TASK]=C2=A0Provide=20correct=20data=20for=20Da?=
 =?UTF-8?q?tabaseLanguageRowsTest?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The dummy data provided in DatabaseLanguageRowsTest
leads to some E_NOTICEs.

This patch aims to provide the minimal correct set of dummy
data needed to run the affected tests without any E_NOTICE

Resolves: #71236
Related: #70584
Releases: master
Change-Id: I159f71325bdd26482ac1bdfb8176ff707acbc036
Reviewed-on: https://review.typo3.org/44470
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
---
 .../backend/Classes/Utility/BackendUtility.php |  2 +-
 .../DatabaseLanguageRowsTest.php               | 18 ++++++++++++++++++
 .../DatabasePageLanguageOverlayRowsTest.php    |  3 ++-
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/typo3/sysext/backend/Classes/Utility/BackendUtility.php b/typo3/sysext/backend/Classes/Utility/BackendUtility.php
index 0986aedfbf19..5a17be26d121 100755
--- a/typo3/sysext/backend/Classes/Utility/BackendUtility.php
+++ b/typo3/sysext/backend/Classes/Utility/BackendUtility.php
@@ -4524,7 +4524,7 @@ class BackendUtility
      */
     public static function versioningPlaceholderClause($table)
     {
-        if ($GLOBALS['TCA'][$table] && static::isTableWorkspaceEnabled($table)) {
+        if (static::isTableWorkspaceEnabled($table)) {
             $currentWorkspace = (int)static::getBackendUserAuthentication()->workspace;
             return ' AND (' . $table . '.t3ver_state <= ' . new VersionState(VersionState::DEFAULT_STATE) . ' OR ' . $table . '.t3ver_wsid = ' . $currentWorkspace . ')';
         }
diff --git a/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/DatabaseLanguageRowsTest.php b/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/DatabaseLanguageRowsTest.php
index c47350052b48..e10dd6659eeb 100644
--- a/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/DatabaseLanguageRowsTest.php
+++ b/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/DatabaseLanguageRowsTest.php
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider;
 use Prophecy\Prophecy\ObjectProphecy;
 use TYPO3\CMS\Backend\Form\Exception\DatabaseDefaultLanguageException;
 use TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseLanguageRows;
+use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Database\DatabaseConnection;
 use TYPO3\CMS\Backend\Configuration\TranslationConfigurationProvider;
 use TYPO3\CMS\Core\Tests\UnitTestCase;
@@ -37,11 +38,19 @@ class DatabaseLanguageRowsTest extends UnitTestCase
      */
     protected $dbProphecy;
 
+    /**
+     * @var BackendUserAuthentication | ObjectProphecy
+     */
+    protected $beUserProphecy;
+
     protected function setUp()
     {
         $this->dbProphecy = $this->prophesize(DatabaseConnection::class);
         $GLOBALS['TYPO3_DB'] = $this->dbProphecy->reveal();
 
+        $this->beUserProphecy = $this->prophesize(BackendUserAuthentication::class);
+        $GLOBALS['BE_USER'] = $this->beUserProphecy;
+
         $this->subject = new DatabaseLanguageRows();
     }
 
@@ -117,6 +126,7 @@ class DatabaseLanguageRowsTest extends UnitTestCase
 
         $defaultLanguageRow = [
             'uid' => 23,
+            'pid' => 123,
             'text' => 'default language text',
             'sys_language_uid' => 0,
         ];
@@ -161,6 +171,7 @@ class DatabaseLanguageRowsTest extends UnitTestCase
 
         $defaultLanguageRow = [
             'uid' => 23,
+            'pid' => 123,
             'text' => 'default language text',
             'sys_language_uid' => 0,
         ];
@@ -219,6 +230,7 @@ class DatabaseLanguageRowsTest extends UnitTestCase
             'translations' => [
                 3 => [
                     'uid' => 43,
+                    'pid' => 32,
                 ],
             ],
         ];
@@ -226,11 +238,13 @@ class DatabaseLanguageRowsTest extends UnitTestCase
         $GLOBALS['TCA']['tt_content'] = array('foo');
         $recordWsolResult = [
             'uid' => 43,
+            'pid' => 32,
             'text' => 'localized text in french',
         ];
 
         $defaultLanguageRow = [
             'uid' => 23,
+            'pid' => 32,
             'text' => 'default language text',
             'sys_language_uid' => 0,
         ];
@@ -251,6 +265,7 @@ class DatabaseLanguageRowsTest extends UnitTestCase
         $expected['additionalLanguageRows'] = [
             3 => [
                 'uid' => 43,
+                'pid' => 32,
                 'text' => 'localized text in french',
             ],
         ];
@@ -314,11 +329,13 @@ class DatabaseLanguageRowsTest extends UnitTestCase
         $GLOBALS['TCA']['tt_content'] = array('foo');
         $recordWsolResult = [
             'uid' => 43,
+            'pid' => 32,
             'text' => 'localized text in french',
         ];
 
         $defaultLanguageRow = [
             'uid' => 23,
+            'pid' => 32,
             'text' => 'default language text',
             'sys_language_uid' => 0,
         ];
@@ -340,6 +357,7 @@ class DatabaseLanguageRowsTest extends UnitTestCase
         $expected['additionalLanguageRows'] = [
             3 => [
                 'uid' => 43,
+                'pid' => 32,
                 'text' => 'localized text in french',
             ],
         ];
diff --git a/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/DatabasePageLanguageOverlayRowsTest.php b/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/DatabasePageLanguageOverlayRowsTest.php
index 07f6862b86a4..72565d263faf 100644
--- a/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/DatabasePageLanguageOverlayRowsTest.php
+++ b/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/DatabasePageLanguageOverlayRowsTest.php
@@ -39,6 +39,7 @@ class DatabasePageLanguageOverlayRowsTest extends UnitTestCase
     {
         $this->dbProphecy = $this->prophesize(DatabaseConnection::class);
         $GLOBALS['TYPO3_DB'] = $this->dbProphecy->reveal();
+        $GLOBALS['TCA']['pages_language_overlay'] = array();
 
         $this->subject = new DatabasePageLanguageOverlayRows();
     }
@@ -51,7 +52,7 @@ class DatabasePageLanguageOverlayRowsTest extends UnitTestCase
         $this->dbProphecy->exec_SELECTgetRows(Argument::cetera())->willReturn(null);
         $this->dbProphecy->sql_error(Argument::cetera())->willReturn(null);
         $this->setExpectedException(\UnexpectedValueException::class,  $this->anything(), 1440777705);
-        $this->subject->addData([]);
+        $this->subject->addData(['effectivePid' => 1]);
     }
 
     /**
-- 
GitLab