Esempio n. 1
0
 /**
  * @dataProvider simpleArrayProvider
  */
 public function testCustomSort(array $array)
 {
     $callable = function ($a, $b) {
         if ($a == $b) {
             return 0;
         }
         return $a < $b ? -1 : 1;
     };
     $ma = new ImmutableArray($array);
     $copiedMa = $ma->customSort($callable, true);
     usort($array, $callable);
     $this->assertTrue($copiedMa !== $ma);
     $this->assertTrue($array === $copiedMa->toArray());
 }
Esempio n. 2
0
 /**
  * @dataProvider simpleArrayProvider
  *
  * @param array $array
  */
 public function testCustomSort(array $array)
 {
     $callable = function ($a, $b) {
         if ($a == $b) {
             return 0;
         }
         return $a < $b ? -1 : 1;
     };
     $arrayzy = new A($array);
     $resultArrayzy = $arrayzy->customSort($callable);
     $resultArray = $array;
     usort($resultArray, $callable);
     $this->assertImmutable($arrayzy, $resultArrayzy, $array, $resultArray);
 }