Simplify CookieComponent::read()

Also, this commit fixes an issue of when the second level key is empty.
Previously, read('foo.0') returned incorrect result.
This commit is contained in:
chinpei215 2017-10-16 21:01:19 +09:00
parent bbea91090d
commit 19bbb7da17
2 changed files with 15 additions and 16 deletions

View file

@ -714,6 +714,20 @@ class CookieComponentTest extends CakeTestCase {
$this->assertEquals(array(), $this->Cookie->read('Array'));
}
/**
* Test reading empty key
*
* @return void
*/
public function testReadEmptyKey() {
$_COOKIE['CakeTestCookie'] = array(
'0' => '{"name":"value"}',
'foo' => array('bar'),
);
$this->assertEquals('value', $this->Cookie->read('0.name'));
$this->assertEquals('bar', $this->Cookie->read('foo.0'));
}
/**
* test that no error is issued for non array data.
*