[TASK] Add tests for BackendUtility::splitTable_Uid 93/56793/2
authorBenni Mack <benni@typo3.org>
Wed, 25 Apr 2018 04:29:12 +0000 (06:29 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Wed, 25 Apr 2018 07:00:13 +0000 (09:00 +0200)
Resolves: #84855
Releases: master
Change-Id: I20c189b082c616590bcb2bdabff9e2f2c22a1bce
Reviewed-on: https://review.typo3.org/56793
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/backend/Tests/Unit/Utility/BackendUtilityTest.php

index 076cdd3..9833341 100644 (file)
@@ -222,7 +222,7 @@ class BackendUtility
 
     /**
      * Makes an backwards explode on the $str and returns an array with ($table, $uid).
-     * Example: tt_content_45 => array('tt_content', 45)
+     * Example: tt_content_45 => ['tt_content', 45]
      *
      * @param string $str [tablename]_[uid] string to explode
      * @return array
index b53df7d..b98265a 100644 (file)
@@ -1212,4 +1212,32 @@ class BackendUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $computedProperties = BackendUtility::purgeComputedPropertiesFromRecord($record);
         self::assertSame($expected, $computedProperties);
     }
+
+    public function splitTableUidDataProvider()
+    {
+        return [
+            'simple' => [
+                'pages_23',
+                ['pages', '23']
+            ],
+            'complex' => [
+                'tt_content_13',
+                ['tt_content', '13']
+            ],
+            'multiple underscores' => [
+                'tx_runaway_domain_model_crime_scene_1234',
+                ['tx_runaway_domain_model_crime_scene', '1234']
+            ]
+        ];
+    }
+
+    /**
+     * @test
+     * @dataProvider splitTableUidDataProvider
+     */
+    public function splitTableUid($input, $expected)
+    {
+        $result = BackendUtility::splitTable_Uid($input);
+        self::assertSame($expected, $result);
+    }
 }