Permalink
Browse files

Fix Hash::get($data, '0')

Fixes #3555
  • Loading branch information...
1 parent efadf3d commit 75495705a60a637406defbb9b9563eda4baaa2e6 @markstory markstory committed Jan 22, 2013
Showing with 9 additions and 1 deletion.
  1. +8 −0 lib/Cake/Test/Case/Utility/HashTest.php
  2. +1 −1 lib/Cake/Utility/Hash.php
@@ -170,6 +170,14 @@ public static function userData() {
* return void
*/
public function testGet() {
+ $data = array('abc', 'def');
+
+ $result = Hash::get($data, '0');
+ $this->assertEquals('abc', $result);
+
+ $result = Hash::get($data, '1');
+ $this->assertEquals('def', $result);
+
$data = self::articleData();
$result = Hash::get(array(), '1.Article.title');
@@ -39,7 +39,7 @@ class Hash {
* @return mixed The value fetched from the array, or null.
*/
public static function get(array $data, $path) {
- if (empty($data) || empty($path)) {
+ if (empty($data)) {
return null;
}
if (is_string($path)) {

0 comments on commit 7549570

Please sign in to comment.