/** * test CCSession::delete */ public function test_delete() { CCSession::set('a', 'b'); CCSession::set('a', 'c', 'file'); $this->assertTrue(CCSession::has('a')); $this->assertTrue(CCSession::has('a', 'file')); CCSession::delete('a'); CCSession::delete('a', 'file'); $this->assertFalse(CCSession::has('a')); $this->assertFalse(CCSession::has('a', 'file')); }
/** * Application initialization. * do your inital stuff here like getting the current user object ect.. * You can return a CCResponse wich will cancle all other actions * if enebaled ( see. main.config -> send_app_wake_response ) * * @return void | CCResponse */ public static function wake() { /* * Start the session by adding the current uri */ CCSession::set('uri', CCServer::uri()); /* * try to authenticate the user */ //static::$user =& CCAuth::handler()->user; /* * load the App configuration */ static::$config = CCConfig::create('app'); }
/** * Handler::create tests */ public function test_create() { $auth = Auth\Handler::create(); $this->assertTrue($auth->user instanceof CCModel); $this->assertFalse($auth->valid()); $auth2 = Auth\Handler::create('other'); $this->assertEquals($auth, Auth\Handler::create()); $this->assertEquals($auth2, Auth\Handler::create('other')); $this->assertNotEquals($auth, $auth2); // create with existing one CCSession::set('user_id', static::$current_user->id); // kill the old instance Auth\Handler::kill_instance('main'); // redo $auth = Auth\Handler::create(); $this->assertTrue($auth->user instanceof CCModel); $this->assertTrue($auth->valid()); // diffrent keys CCSession::set('user_email', static::$current_user->email); $auth = Auth\Handler::create('diffrent_selector_keys'); $this->assertTrue($auth->user instanceof CCModel); $this->assertTrue($auth->valid()); // another auth same session manager $auth = Auth\Handler::create('same_session_manager'); $this->assertTrue($auth->user instanceof CCModel); $this->assertTrue($auth->valid()); // another auth diffrent session manager $auth = Auth\Handler::create('diffrent_session_manager'); $this->assertTrue($auth->user instanceof CCModel); $this->assertFalse($auth->valid()); // using an config alias $auth = Auth\Handler::create('alias'); $this->assertTrue($auth->user instanceof CCModel); $this->assertTrue($auth->valid()); // overwrite config $auth = Auth\Handler::create('main', array('session_manager' => 'array')); $this->assertTrue($auth->user instanceof CCModel); $this->assertFalse($auth->valid()); // test user_id but user dont exists Auth\Handler::kill_instance('main'); $auth = Auth\Handler::create('main'); $auth->session->set('user_id', 21); Auth\Handler::kill_instance('main'); $auth = Auth\Handler::create('main'); $this->assertTrue($auth->user instanceof CCModel); $this->assertFalse($auth->valid()); }