diff --git a/cake/libs/controller/components/session.php b/cake/libs/controller/components/session.php index 4bb4b65d2..282ce55d5 100644 --- a/cake/libs/controller/components/session.php +++ b/cake/libs/controller/components/session.php @@ -31,14 +31,16 @@ if (!class_exists('cakesession')) { * @link http://book.cakephp.org/view/1310/Sessions * */ -class SessionComponent extends Object { +class SessionComponent extends Component { /** - * Constructor + * Constructor automatically starts the session. * - * @return void + * @param ComponentCollection $collection A ComponentCollection this component can use to lazy load its components + * @param array $settings Array of configuration settings. */ - public function __construct() { + public function __construct(ComponentCollection $collection, $settings = array()) { + parent::__construct($collection, $settings); CakeSession::start(); } diff --git a/cake/tests/cases/libs/controller/components/session.test.php b/cake/tests/cases/libs/controller/components/session.test.php index a381d49a7..5c9d2cf44 100644 --- a/cake/tests/cases/libs/controller/components/session.test.php +++ b/cake/tests/cases/libs/controller/components/session.test.php @@ -121,6 +121,7 @@ class SessionComponentTest extends CakeTestCase { function setUp() { parent::setUp(); $_SESSION = null; + $this->ComponentCollection = new ComponentCollection(); } /** @@ -141,11 +142,11 @@ class SessionComponentTest extends CakeTestCase { * @return void */ function testSessionIdConsistentAcrossRequestAction() { - $Session = new SessionComponent(); + $Session = new SessionComponent($this->ComponentCollection); $this->assertTrue(isset($_SESSION)); $Object = new Object(); - $Session = new SessionComponent(); + $Session = new SessionComponent($this->ComponentCollection); $expected = $Session->id(); $result = $Object->requestAction('/session_test/session_id'); @@ -162,7 +163,7 @@ class SessionComponentTest extends CakeTestCase { * @return void */ function testSessionValid() { - $Session = new SessionComponent(); + $Session = new SessionComponent($this->ComponentCollection); $this->assertTrue($Session->valid()); @@ -170,7 +171,7 @@ class SessionComponentTest extends CakeTestCase { $Session->userAgent('rweerw'); $this->assertFalse($Session->valid()); - $Session = new SessionComponent(); + $Session = new SessionComponent($this->ComponentCollection); $Session->time = $Session->read('Config.time') + 1; $this->assertFalse($Session->valid()); } @@ -182,7 +183,7 @@ class SessionComponentTest extends CakeTestCase { * @return void */ function testSessionError() { - $Session = new SessionComponent(); + $Session = new SessionComponent($this->ComponentCollection); $this->assertFalse($Session->error()); } @@ -193,7 +194,7 @@ class SessionComponentTest extends CakeTestCase { * @return void */ function testSessionReadWrite() { - $Session = new SessionComponent(); + $Session = new SessionComponent($this->ComponentCollection); $this->assertNull($Session->read('Test')); @@ -227,7 +228,7 @@ class SessionComponentTest extends CakeTestCase { * @return void */ function testSessionDelete() { - $Session = new SessionComponent(); + $Session = new SessionComponent($this->ComponentCollection); $this->assertFalse($Session->delete('Test')); @@ -242,7 +243,7 @@ class SessionComponentTest extends CakeTestCase { * @return void */ function testSessionCheck() { - $Session = new SessionComponent(); + $Session = new SessionComponent($this->ComponentCollection); $this->assertFalse($Session->check('Test')); @@ -258,7 +259,7 @@ class SessionComponentTest extends CakeTestCase { * @return void */ function testSessionFlash() { - $Session = new SessionComponent(); + $Session = new SessionComponent($this->ComponentCollection); $this->assertNull($Session->read('Message.flash')); @@ -285,7 +286,7 @@ class SessionComponentTest extends CakeTestCase { */ function testSessionId() { unset($_SESSION); - $Session = new SessionComponent(); + $Session = new SessionComponent($this->ComponentCollection); $this->assertEquals(session_id(), $Session->id()); } @@ -296,7 +297,7 @@ class SessionComponentTest extends CakeTestCase { * @return void */ function testSessionDestroy() { - $Session = new SessionComponent(); + $Session = new SessionComponent($this->ComponentCollection); $Session->write('Test', 'some value'); $this->assertEqual($Session->read('Test'), 'some value');