예제 #1
0
 public function test_selectKey()
 {
     $xyz = new Collection(array('x' => 10, 'y' => 20, 'z' => 30));
     $this->assertSame(array(10, 20, 30), $xyz->selectKey(null)->toArray(), 'null should return an index array.');
     $this->assertSame(array(10 => 10, 20 => 20, 30 => 30), $xyz->selectKey('.')->toArray(), 'Using a path as key.');
     $closure = function ($item, $key) {
         return $key . $item;
     };
     $this->assertSame(array('x10' => 10, 'y20' => 20, 'z30' => 30), $xyz->selectKey($closure)->toArray(), 'Using a closure as key.');
 }