/** * Test getValue */ public function testGetValueDefault() { $arr = array('foo' => 'bar', 'baz' => '', 'fiz' => 0); $this->assertEquals('bar', Arr::getValue($arr, 'foo', 'default'), 'foo should be bar'); $this->assertEquals('default', Arr::getValue($arr, 'buz', 'default'), 'default should be step in'); $this->assertEquals(0, Arr::getValue($arr, 'fiz', 'default'), 'fiz should be 0'); }
public function testGetValueDefault() { $testArray = ['key' => 'value']; $this->assertEquals('default', Arr::getValue($testArray, 'nonExistingKey', 'default')); }
/** * @test */ public function nullWillBeReturnedForInvalidKey() { $array = array('name' => 'My Name'); $this->assertNull(Arr::getValue('undefined', $array)); }