[TASK] Make array utility test do not depend on undefined behaviour 55/36055/4
authorTymoteusz Motylewski <t.motylewski@gmail.com>
Fri, 16 Jan 2015 21:44:27 +0000 (22:44 +0100)
committerMarkus Klein <klein.t3@reelworx.at>
Sat, 17 Jan 2015 12:30:49 +0000 (13:30 +0100)
ArrayUtilityTests expect that order of elements with the same value
will not change. PHP doesn't guarantee that, so it doesn't make
sense to test this behaviour.

This test fails under HHVM which has different sorting
implementation than PHP 5.

Actually PHP 7 is going into the same direction, so sooner
or later this test will fail also under PHP.
See https://github.com/php/php-src/pull/999
and https://github.com/facebook/hhvm/issues/4649

Resolves: #64322
Releases: master
Change-Id: Ie48e57456eee20ff9b1a0efc0ac38413f16c5de1
Reviewed-on: http://review.typo3.org/36055
Reviewed-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Tested-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/core/Tests/Unit/Utility/ArrayUtilityTest.php

index 65f0175..175a304 100644 (file)
@@ -807,7 +807,7 @@ class ArrayUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                                array(
                                        '22' => array(
                                                'uid' => '22',
-                                               'title' => 'b',
+                                               'title' => 'c',
                                                'dummy' => 2
                                        ),
                                        '24' => array(
@@ -817,26 +817,26 @@ class ArrayUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                                        ),
                                        '23' => array(
                                                'uid' => '23',
-                                               'title' => 'a',
+                                               'title' => 'b',
                                                'dummy' => 4
                                        ),
                                ),
                                'title',
                                TRUE,
                                array(
-                                       '23' => array(
-                                               'uid' => '23',
-                                               'title' => 'a',
-                                               'dummy' => 4
-                                       ),
                                        '24' => array(
                                                'uid' => '24',
                                                'title' => 'a',
                                                'dummy' => 3
                                        ),
+                                       '23' => array(
+                                               'uid' => '23',
+                                               'title' => 'b',
+                                               'dummy' => 4
+                                       ),
                                        '22' => array(
                                                'uid' => '22',
-                                               'title' => 'b',
+                                               'title' => 'c',
                                                'dummy' => 2
                                        ),
                                ),
@@ -845,7 +845,7 @@ class ArrayUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                                array(
                                        22 => array(
                                                'uid' => '22',
-                                               'title' => 'b',
+                                               'title' => 'c',
                                                'dummy' => 2
                                        ),
                                        24 => array(
@@ -855,26 +855,26 @@ class ArrayUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                                        ),
                                        23 => array(
                                                'uid' => '23',
-                                               'title' => 'a',
+                                               'title' => 'b',
                                                'dummy' => 4
                                        ),
                                ),
                                'title',
                                TRUE,
                                array(
-                                       23 => array(
-                                               'uid' => '23',
-                                               'title' => 'a',
-                                               'dummy' => 4
-                                       ),
                                        24 => array(
                                                'uid' => '24',
                                                'title' => 'a',
                                                'dummy' => 3
                                        ),
+                                       23 => array(
+                                               'uid' => '23',
+                                               'title' => 'b',
+                                               'dummy' => 4
+                                       ),
                                        22 => array(
                                                'uid' => '22',
-                                               'title' => 'b',
+                                               'title' => 'c',
                                                'dummy' => 2
                                        ),
                                ),
@@ -883,12 +883,12 @@ class ArrayUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                                array(
                                        23 => array(
                                                'uid' => '23',
-                                               'title' => 'a',
+                                               'title' => 'b',
                                                'dummy' => 4
                                        ),
                                        22 => array(
                                                'uid' => '22',
-                                               'title' => 'b',
+                                               'title' => 'c',
                                                'dummy' => 2
                                        ),
                                        24 => array(
@@ -902,19 +902,19 @@ class ArrayUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                                array(
                                        22 => array(
                                                'uid' => '22',
-                                               'title' => 'b',
+                                               'title' => 'c',
                                                'dummy' => 2
                                        ),
+                                       23 => array(
+                                               'uid' => '23',
+                                               'title' => 'b',
+                                               'dummy' => 4
+                                       ),
                                        24 => array(
                                                'uid' => '24',
                                                'title' => 'a',
                                                'dummy' => 3
                                        ),
-                                       23 => array(
-                                               'uid' => '23',
-                                               'title' => 'a',
-                                               'dummy' => 4
-                                       ),
                                ),
                        ),
                );
@@ -930,7 +930,7 @@ class ArrayUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        public function sortArraysByKeyCheckIfSortingIsCorrect(array $array, $key, $ascending, $expectedResult) {
                $sortedArray = ArrayUtility::sortArraysByKey($array, $key, $ascending);
-               $this->assertSame($sortedArray, $expectedResult);
+               $this->assertSame($expectedResult, $sortedArray);
        }
 
        /**