Exemplo n.º 1
0
 public function testPull()
 {
     $array = ['name' => 'Desk', 'price' => 100];
     $name = Arr::pull($array, 'name');
     $this->assertEquals('Desk', $name);
     $this->assertEquals(['price' => 100], $array);
     // Only works on first level keys
     $array = ['*****@*****.**' => 'Joe', 'jane@localhost' => 'Jane'];
     $name = Arr::pull($array, '*****@*****.**');
     $this->assertEquals('Joe', $name);
     $this->assertEquals(['jane@localhost' => 'Jane'], $array);
     // Does not work for nested keys
     $array = ['emails' => ['*****@*****.**' => 'Joe', 'jane@localhost' => 'Jane']];
     $name = Arr::pull($array, '*****@*****.**');
     $this->assertEquals(null, $name);
     $this->assertEquals(['emails' => ['*****@*****.**' => 'Joe', 'jane@localhost' => 'Jane']], $array);
 }