[TASK] Make L10nModeUpdaterTest notice free 84/56184/2
authorJan Helke <typo3@helke.de>
Thu, 15 Mar 2018 17:53:23 +0000 (18:53 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 15 Mar 2018 18:41:37 +0000 (19:41 +0100)
Resolves: #84311
Releases: master
Change-Id: I494b83a27e333eed77837bee2586e448f5903566
Reviewed-on: https://review.typo3.org/56184
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de>
Tested-by: Mathias Brodala <mbrodala@pagemachine.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/install/Classes/Updates/RowUpdater/L10nModeUpdater.php
typo3/sysext/install/Tests/Unit/Updates/RowUpdater/L10nModeUpdaterTest.php

index 2966574..7bf98f7 100644 (file)
@@ -178,7 +178,7 @@ class L10nModeUpdater implements RowUpdaterInterface
      */
     protected function getL10nModePayloadForTable(string $tableName): array
     {
-        if (!is_array($GLOBALS['TCA'][$tableName])) {
+        if (!isset($GLOBALS['TCA'][$tableName]) || !\is_array($GLOBALS['TCA'][$tableName])) {
             throw new \RuntimeException(
                 'Globals TCA of given table name must exist',
                 1484176136
index d72ee36..ce2e277 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+declare(strict_types=1);
 namespace TYPO3\CMS\Install\Tests\Unit\Updates\RowUpdater;
 
 /*
@@ -29,17 +30,24 @@ use TYPO3\CMS\Install\Updates\RowUpdater\L10nModeUpdater;
 class L10nModeUpdaterTest extends BaseTestCase
 {
     /**
-     * Subject is not notice free, disable E_NOTICES
+     * @test
      */
-    protected static $suppressNotices = true;
+    public function hasPotentialUpdateForTableThrowsExceptionIfGlobalsTcaTableArrayIsNotSet()
+    {
+        $this->expectException(\RuntimeException::class);
+        $this->expectExceptionCode(1484176136);
+        $GLOBALS['TCA'] = [];
+        (new L10nModeUpdater())->hasPotentialUpdateForTable('someTable');
+    }
 
     /**
      * @test
      */
-    public function hasPotentialUpdateForTableThrowsExceptionIfGlobalsTcaIsNoArray()
+    public function hasPotentialUpdateForTableThrowsExceptionIfGlobalsTcaTableArrayIsNotAnArray()
     {
         $this->expectException(\RuntimeException::class);
         $this->expectExceptionCode(1484176136);
+        $GLOBALS['TCA'] = ['someTable' => ''];
         (new L10nModeUpdater())->hasPotentialUpdateForTable('someTable');
     }