Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add casting to make CookieComponent more backwards compatible.
Add casting that allows CookieComponent to continue working with loose
typing that was supported in earlier versions.

Refs #11120
  • Loading branch information
markstory committed Aug 31, 2017
1 parent 95b0de3 commit 2e0d6b1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Controller/Component/CookieComponent.php
Expand Up @@ -316,8 +316,8 @@ protected function _write($name, $value)
'expire' => $expires->format('U'),
'path' => $config['path'],
'domain' => $config['domain'],
'secure' => $config['secure'],
'httpOnly' => $config['httpOnly']
'secure' => (bool)$config['secure'],
'httpOnly' => (bool)$config['httpOnly']
]);
}

Expand Down
19 changes: 19 additions & 0 deletions tests/TestCase/Controller/Component/CookieComponentTest.php
Expand Up @@ -105,6 +105,25 @@ public function testConfigKeyArray()
$this->assertEquals($expected, $result);
}

/**
* Test backwards compatibility with settings that use type juggling.
*
* @return void
*/
public function testSettingsCompatibility()
{
$this->Cookie->config([
'expires' => '+10 seconds',
'path' => '/',
'domain' => '',
'secure' => 0,
'key' => 'somerandomhaskeysomerandomhaskey',
'encryption' => 0,
]);
$this->Cookie->write('key', 'value');
$this->assertSame('value', $this->Cookie->read('key'));
}

/**
* sets up some default cookie data.
*
Expand Down

0 comments on commit 2e0d6b1

Please sign in to comment.