diff --git a/lib/Cake/Test/Case/Utility/HashTest.php b/lib/Cake/Test/Case/Utility/HashTest.php index 761ce626f..dfe4f4940 100644 --- a/lib/Cake/Test/Case/Utility/HashTest.php +++ b/lib/Cake/Test/Case/Utility/HashTest.php @@ -1113,6 +1113,28 @@ class HashTest extends CakeTestCase { $this->assertEquals('value', $result[0]['Comment'][1]['insert']); } +/** + * Test that insert() can insert data over a string value. + * + * @return void + */ + public function testInsertOverwriteStringValue() { + $data = array( + 'Some' => array( + 'string' => 'value' + ) + ); + $result = Set::insert($data, 'Some.string.value', array('values')); + $expected = array( + 'Some' => array( + 'string' => array( + 'value' => array( 'values') + ) + ) + ); + $this->assertEquals($expected, $result); + } + /** * Test remove() method. * diff --git a/lib/Cake/Utility/Hash.php b/lib/Cake/Utility/Hash.php index ec1689027..4116161fe 100644 --- a/lib/Cake/Utility/Hash.php +++ b/lib/Cake/Utility/Hash.php @@ -270,7 +270,7 @@ class Hash { $_list =& $_list[$key]; } if (!is_array($_list)) { - return array(); + $_list = array(); } } if ($op === 'remove') {