Deprecating CakeSession::del(), use delete() instead.

Updating file headers.
Updating test cases.
This commit is contained in:
mark_story 2009-10-02 13:11:43 -04:00
parent 32d5b40cd0
commit 4794680444
3 changed files with 23 additions and 22 deletions

View file

@ -1,6 +1,4 @@
<?php
/* SVN FILE: $Id$ */
/**
* Session class for Cake.
*
@ -12,20 +10,17 @@
* PHP versions 4 and 5
*
* CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org)
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
* @package cake
* @subpackage cake.cake.libs
* @since CakePHP(tm) v .0.10.0.1222
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
@ -243,6 +238,17 @@ class CakeSession extends Object {
}
}
/**
* Remove a variable from the session
*
* @return boolean
* @deprecated Use CakeSession::delete instead
**/
function del($name) {
trigger_error('CakeSession::del() is deprecated, use CakeSession::delete() instead.', E_USER_WARNING);
return $this->delete($name);
}
/**
* Removes a variable from session.
*
@ -250,7 +256,7 @@ class CakeSession extends Object {
* @return boolean Success
* @access public
*/
function del($name) {
function delete($name) {
if ($this->check($name)) {
if ($var = $this->__validateKeys($name)) {
if (in_array($var, $this->watchKeys)) {

View file

@ -183,7 +183,7 @@ class SessionComponent extends CakeSession {
function delete($name) {
if ($this->__active === true) {
$this->__start();
return parent::del($name);
return parent::delete($name);
}
return false;
}

View file

@ -1,6 +1,4 @@
<?php
/* SVN FILE: $Id$ */
/**
* SessionTest file
*
@ -9,20 +7,17 @@
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
*
* Licensed under The Open Group Test Suite License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.4206
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
if (!class_exists('CakeSession')) {
@ -190,7 +185,7 @@ class SessionTest extends CakeTestCase {
$result = $this->Session->error();
$this->assertEqual($result, "Does.not.exist doesn't exist");
$this->Session->del('Failing.delete');
$this->Session->delete('Failing.delete');
$result = $this->Session->error();
$this->assertEqual($result, "Failing.delete doesn't exist");
}
@ -201,14 +196,14 @@ class SessionTest extends CakeTestCase {
* @access public
* @return void
*/
function testDel() {
function testDelete() {
$this->assertTrue($this->Session->write('Delete.me', 'Clearing out'));
$this->assertTrue($this->Session->del('Delete.me'));
$this->assertTrue($this->Session->delete('Delete.me'));
$this->assertFalse($this->Session->check('Delete.me'));
$this->assertTrue($this->Session->check('Delete'));
$this->assertTrue($this->Session->write('Clearing.sale', 'everything must go'));
$this->assertTrue($this->Session->del('Clearing'));
$this->assertTrue($this->Session->delete('Clearing'));
$this->assertFalse($this->Session->check('Clearing.sale'));
$this->assertFalse($this->Session->check('Clearing'));
}
@ -228,7 +223,7 @@ class SessionTest extends CakeTestCase {
$this->Session->write('Watching', 'They found us!');
$this->expectError('Deleting session key {Watching}');
$this->Session->del('Watching');
$this->Session->delete('Watching');
$this->assertFalse($this->Session->watch('Invalid.key'));
}
@ -289,7 +284,7 @@ class SessionTest extends CakeTestCase {
function testCheckKeyWithSpaces() {
$this->assertTrue($this->Session->write('Session Test', "test"));
$this->assertEqual($this->Session->check('Session Test'), 'test');
$this->Session->del('Session Test');
$this->Session->delete('Session Test');
$this->assertTrue($this->Session->write('Session Test.Test Case', "test"));
$this->assertTrue($this->Session->check('Session Test.Test Case'));