Skip to content
Permalink
Browse files

Making SessionComponent extend Component. Updating test case.

  • Loading branch information...
markstory committed Jul 31, 2010
1 parent 6dbe5b0 commit db1acb461a903f2327b5e6af3922d31e6028aa50
@@ -31,14 +31,16 @@
* @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();
}
@@ -121,6 +121,7 @@ public static function teardownAfterClass() {
function setUp() {
parent::setUp();
$_SESSION = null;
$this->ComponentCollection = new ComponentCollection();
}
/**
@@ -141,11 +142,11 @@ function tearDown() {
* @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,15 +163,15 @@ function testSessionIdConsistentAcrossRequestAction() {
* @return void
*/
function testSessionValid() {
$Session = new SessionComponent();
$Session = new SessionComponent($this->ComponentCollection);
$this->assertTrue($Session->valid());
Configure::write('Session.checkAgent', true);
$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 @@ function testSessionValid() {
* @return void
*/
function testSessionError() {
$Session = new SessionComponent();
$Session = new SessionComponent($this->ComponentCollection);
$this->assertFalse($Session->error());
}
@@ -193,7 +194,7 @@ function testSessionError() {
* @return void
*/
function testSessionReadWrite() {
$Session = new SessionComponent();
$Session = new SessionComponent($this->ComponentCollection);
$this->assertNull($Session->read('Test'));
@@ -227,7 +228,7 @@ function testSessionReadWrite() {
* @return void
*/
function testSessionDelete() {
$Session = new SessionComponent();
$Session = new SessionComponent($this->ComponentCollection);
$this->assertFalse($Session->delete('Test'));
@@ -242,7 +243,7 @@ function testSessionDelete() {
* @return void
*/
function testSessionCheck() {
$Session = new SessionComponent();
$Session = new SessionComponent($this->ComponentCollection);
$this->assertFalse($Session->check('Test'));
@@ -258,7 +259,7 @@ function testSessionCheck() {
* @return void
*/
function testSessionFlash() {
$Session = new SessionComponent();
$Session = new SessionComponent($this->ComponentCollection);
$this->assertNull($Session->read('Message.flash'));
@@ -285,7 +286,7 @@ function testSessionFlash() {
*/
function testSessionId() {
unset($_SESSION);
$Session = new SessionComponent();
$Session = new SessionComponent($this->ComponentCollection);
$this->assertEquals(session_id(), $Session->id());
}
@@ -296,7 +297,7 @@ function testSessionId() {
* @return void
*/
function testSessionDestroy() {
$Session = new SessionComponent();
$Session = new SessionComponent($this->ComponentCollection);
$Session->write('Test', 'some value');
$this->assertEqual($Session->read('Test'), 'some value');

0 comments on commit db1acb4

Please sign in to comment.
You can’t perform that action at this time.