Move initialize logic to __construct().

Fixes #2582
This commit is contained in:
mark_story 2012-02-15 14:06:13 -05:00
parent 55f63bbd5b
commit 6fda055a1e
2 changed files with 6 additions and 14 deletions

View file

@ -172,16 +172,9 @@ class CookieComponent extends Component {
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')));

View file

@ -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 @@ class CookieComponentTest extends CakeTestCase {
'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 @@ class CookieComponentTest extends CakeTestCase {
'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);
}