|
|
@@ -471,6 +471,19 @@ class CookieComponentTest extends CakeTestCase {
|
|
|
unset($_COOKIE['CakeTestCookie']);
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Test Reading legacy cookie values.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ function testReadLegacyCookieValue() {
|
|
|
+ $_COOKIE['CakeTestCookie'] = array(
|
|
|
+ 'Legacy' => array('value' => $this->_oldImplode(array(1, 2, 3)))
|
|
|
+ );
|
|
|
+ $result = $this->Cookie->read('Legacy.value');
|
|
|
+ $expected = array(1, 2, 3);
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* test that no error is issued for non array data.
|
|
|
@@ -485,14 +498,11 @@ class CookieComponentTest extends CakeTestCase {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Implode method to keep keys are multidimensional arrays
|
|
|
+ * Helper method for generating old style encoded cookie values.
|
|
|
*
|
|
|
- * @param array $array Map of key and values
|
|
|
- * @return string String in the form key1|value1,key2|value2
|
|
|
+ * @return string.
|
|
|
*/
|
|
|
- protected function _implode(array $array) {
|
|
|
- return json_encode($array);
|
|
|
-
|
|
|
+ protected function _oldImplode(array $array) {
|
|
|
$string = '';
|
|
|
foreach ($array as $key => $value) {
|
|
|
$string .= ',' . $key . '|' . $value;
|
|
|
@@ -501,6 +511,16 @@ class CookieComponentTest extends CakeTestCase {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Implode method to keep keys are multidimensional arrays
|
|
|
+ *
|
|
|
+ * @param array $array Map of key and values
|
|
|
+ * @return string String in the form key1|value1,key2|value2
|
|
|
+ */
|
|
|
+ protected function _implode(array $array) {
|
|
|
+ return json_encode($array);
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
* encrypt method
|
|
|
*
|
|
|
* @param mixed $value
|