/** * @dataProvider simpleArrayProvider */ public function testCustomSortKeys(array $array) { $callable = function ($a, $b) { if ($a == $b) { return 0; } return $a > $b ? -1 : 1; }; $ma = new MutableArray($array); $copiedMa = $ma->customSortKeys($callable, true); uksort($array, $callable); $this->assertTrue($copiedMa === $ma); $this->assertTrue($array === $ma->toArray()); }
/** * @dataProvider simpleArrayProvider * * @param array $array */ public function testCustomSortKeys(array $array) { $callable = function ($a, $b) { if ($a == $b) { return 0; } return $a > $b ? -1 : 1; }; $arrayzy = new A($array); $resultArrayzy = $arrayzy->customSortKeys($callable); $resultArray = $array; uksort($resultArray, $callable); $this->assertMutable($arrayzy, $resultArrayzy, $resultArray); }