mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Changing FormatColumns to refer to model->alias instead of model->name
Test case modified to use a unique class name (to allow test groups to run) git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7427 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
c917c611dc
commit
903b78d108
2 changed files with 26 additions and 17 deletions
|
@ -240,7 +240,7 @@ class Sanitize {
|
||||||
*/
|
*/
|
||||||
function formatColumns(&$model) {
|
function formatColumns(&$model) {
|
||||||
foreach ($model->data as $name => $values) {
|
foreach ($model->data as $name => $values) {
|
||||||
if ($name == $model->name) {
|
if ($name == $model->alias) {
|
||||||
$curModel =& $model;
|
$curModel =& $model;
|
||||||
} elseif (isset($model->{$name}) && is_object($model->{$name}) && is_subclass_of($model->{$name}, 'Model')) {
|
} elseif (isset($model->{$name}) && is_object($model->{$name}) && is_subclass_of($model->{$name}, 'Model')) {
|
||||||
$curModel =& $model->{$name};
|
$curModel =& $model->{$name};
|
||||||
|
|
|
@ -27,40 +27,49 @@
|
||||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||||
*/
|
*/
|
||||||
App::import('Core', 'Sanitize');
|
App::import('Core', 'Sanitize');
|
||||||
|
|
||||||
if (!class_exists('DataTest')) {
|
|
||||||
/**
|
/**
|
||||||
* DataTest class
|
* DataTest class
|
||||||
*
|
*
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.tests.cases.libs
|
* @subpackage cake.tests.cases.libs
|
||||||
*/
|
*/
|
||||||
class DataTest extends CakeTestModel {
|
class SanitizeDataTest extends CakeTestModel {
|
||||||
/**
|
/**
|
||||||
* name property
|
* name property
|
||||||
*
|
*
|
||||||
* @var string 'DataTest'
|
* @var string 'SanitizeDataTest'
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $name = 'DataTest';
|
var $name = 'SanitizeDataTest';
|
||||||
}
|
/**
|
||||||
|
* useTable property
|
||||||
|
*
|
||||||
|
* @var string 'data_tests'
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
var $useTable = 'data_tests';
|
||||||
}
|
}
|
||||||
if (!class_exists('Article')) {
|
|
||||||
/**
|
/**
|
||||||
* Article class
|
* Article class
|
||||||
*
|
*
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.tests.cases.libs
|
* @subpackage cake.tests.cases.libs
|
||||||
*/
|
*/
|
||||||
class Article extends CakeTestModel {
|
class SanitizeArticle extends CakeTestModel {
|
||||||
/**
|
/**
|
||||||
* name property
|
* name property
|
||||||
*
|
*
|
||||||
* @var string 'Article'
|
* @var string 'Article'
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $name = 'Article';
|
var $name = 'SanitizeArticle';
|
||||||
}
|
/**
|
||||||
|
* useTable property
|
||||||
|
*
|
||||||
|
* @var string 'articles'
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
var $useTable = 'articles';
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
|
@ -69,21 +78,21 @@ if (!class_exists('Article')) {
|
||||||
* @subpackage cake.tests.cases.libs
|
* @subpackage cake.tests.cases.libs
|
||||||
*/
|
*/
|
||||||
class SanitizeTest extends CakeTestCase {
|
class SanitizeTest extends CakeTestCase {
|
||||||
/**
|
/**
|
||||||
* autoFixtures property
|
* autoFixtures property
|
||||||
*
|
*
|
||||||
* @var bool false
|
* @var bool false
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $autoFixtures = false;
|
var $autoFixtures = false;
|
||||||
/**
|
/**
|
||||||
* fixtures property
|
* fixtures property
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $fixtures = array('core.data_test', 'core.article');
|
var $fixtures = array('core.data_test', 'core.article');
|
||||||
/**
|
/**
|
||||||
* startTest method
|
* startTest method
|
||||||
*
|
*
|
||||||
* @param mixed $method
|
* @param mixed $method
|
||||||
|
@ -378,7 +387,7 @@ class SanitizeTest extends CakeTestCase {
|
||||||
function testFormatColumns() {
|
function testFormatColumns() {
|
||||||
$this->loadFixtures('DataTest', 'Article');
|
$this->loadFixtures('DataTest', 'Article');
|
||||||
|
|
||||||
$this->DataTest =& new DataTest();
|
$this->DataTest =& new SanitizeDataTest(array('alias' => 'DataTest'));
|
||||||
$data = array('DataTest' => array(
|
$data = array('DataTest' => array(
|
||||||
'id' => 'z',
|
'id' => 'z',
|
||||||
'count' => '12a',
|
'count' => '12a',
|
||||||
|
@ -397,7 +406,7 @@ class SanitizeTest extends CakeTestCase {
|
||||||
$result = $this->DataTest->data;
|
$result = $this->DataTest->data;
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$this->Article =& new Article();
|
$this->Article =& new SanitizeArticle(array('alias' => 'Article'));
|
||||||
$data = array('Article' => array(
|
$data = array('Article' => array(
|
||||||
'id' => 'ZB',
|
'id' => 'ZB',
|
||||||
'user_id' => '12',
|
'user_id' => '12',
|
||||||
|
@ -419,4 +428,4 @@ class SanitizeTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Add table
Reference in a new issue