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:
AD7six 2008-08-03 15:32:33 +00:00
parent c917c611dc
commit 903b78d108
2 changed files with 26 additions and 17 deletions

View file

@ -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};

View file

@ -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.
@ -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',