Permalink
Browse files

Move initialize logic to __construct().

Fixes #2582
  • Loading branch information...
1 parent 55f63bb commit 6fda055a1e72f49e88ee9b60b47aeb455982b0db @markstory markstory committed Feb 15, 2012
@@ -172,16 +172,9 @@ public function __construct(ComponentCollection $collection, $settings = array()
if (isset($this->time)) {
$this->_expire($this->time);
}
- }
-/**
- * Initialize CookieComponent
- *
- * @param Controller $controller
- * @return void
- */
- public function initialize($controller) {
- if (is_object($controller) && isset($controller->response)) {
+ $controller = $collection->getController();
+ if ($controller && isset($controller->response)) {
$this->_response = $controller->response;
} else {
$this->_response = new CakeResponse(array('charset' => Configure::read('App.encoding')));
@@ -72,10 +72,9 @@ class CookieComponentTest extends CakeTestCase {
*/
public function setUp() {
$_COOKIE = array();
- $Collection = new ComponentCollection();
- $this->Cookie = new CookieComponent($Collection);
$this->Controller = new CookieComponentTestController(new CakeRequest(), new CakeResponse());
- $this->Cookie->initialize($this->Controller);
+ $this->Controller->constructClasses();
+ $this->Cookie = $this->Controller->Cookie;
$this->Cookie->name = 'CakeTestCookie';
$this->Cookie->time = 10;
@@ -199,7 +198,7 @@ public function testWriteHttpOnly() {
'domain' => '',
'secure' => false,
'httpOnly' => true);
- $result = $this->Controller->response->cookie($this->Cookie->name.'[Testing]');
+ $result = $this->Controller->response->cookie($this->Cookie->name . '[Testing]');
$this->assertEquals($result, $expected);
}
@@ -220,7 +219,7 @@ public function testDeleteHttpOnly() {
'domain' => '',
'secure' => false,
'httpOnly' => true);
- $result = $this->Controller->response->cookie($this->Cookie->name.'[Testing]');
+ $result = $this->Controller->response->cookie($this->Cookie->name . '[Testing]');
$this->assertEquals($result, $expected);
}

0 comments on commit 6fda055

Please sign in to comment.