Fixing conflict of class names between tests

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4885 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mariano.iglesias 2007-04-26 12:02:51 +00:00
parent 6d058861e7
commit 45625d65a9

View file

@ -129,12 +129,12 @@
* @package cake.tests * @package cake.tests
* @subpackage cake.tests.cases.libs.view.helpers * @subpackage cake.tests.cases.libs.view.helpers
*/ */
class User extends Model { class ValidateUser extends Model {
var $primaryKey = 'id'; var $primaryKey = 'id';
var $useTable = false; var $useTable = false;
var $name = 'User'; var $name = 'ValidateUser';
var $hasOne = array('Profile' => array( var $hasOne = array('ValidateProfile' => array(
'className' => 'Profile', 'className' => 'ValidateProfile',
'foreignKey' => 'user_id' 'foreignKey' => 'user_id'
)); ));
@ -160,16 +160,16 @@
* @package cake.tests * @package cake.tests
* @subpackage cake.tests.cases.libs.view.helpers * @subpackage cake.tests.cases.libs.view.helpers
*/ */
class Profile extends Model { class ValidateProfile extends Model {
var $primaryKey = 'id'; var $primaryKey = 'id';
var $useTable = false; var $useTable = false;
var $name = 'Profile'; var $name = 'ValidateProfile';
var $hasOne = array('Item' => array( var $hasOne = array('ValidateItem' => array(
'className' => 'Item', 'className' => 'ValidateItem',
'foreignKey' => 'profile_id' 'foreignKey' => 'profile_id'
)); ));
var $belongsTo = array('User' => array( var $belongsTo = array('ValidateUser' => array(
'className' => 'User', 'className' => 'ValidateUser',
'foreignKey' => 'user_id' 'foreignKey' => 'user_id'
)); ));
@ -197,12 +197,12 @@
* @package cake.tests * @package cake.tests
* @subpackage cake.tests.cases.libs.view.helpers * @subpackage cake.tests.cases.libs.view.helpers
*/ */
class Item extends Model { class ValidateItem extends Model {
var $primaryKey = 'id'; var $primaryKey = 'id';
var $useTable = false; var $useTable = false;
var $name = 'Item'; var $name = 'ValidateItem';
var $belongsTo = array('Profile' => array( var $belongsTo = array('ValidateProfile' => array(
'className' => 'Profile', 'className' => 'ValidateProfile',
'foreignKey' => 'profile_id' 'foreignKey' => 'profile_id'
)); ));
@ -277,35 +277,35 @@ class FormHelperTest extends CakeTestCase {
} }
function testFormValidationAssociatedFirstLevel() { function testFormValidationAssociatedFirstLevel() {
$this->User =& new User(); $this->ValidateUser =& new ValidateUser();
$this->User->Profile =& new Profile(); $this->ValidateUser->ValidateProfile =& new ValidateProfile();
$data = array( $data = array(
'User' => array( 'ValidateUser' => array(
'name' => 'mariano' 'name' => 'mariano'
), ),
'Profile' => array( 'ValidateProfile' => array(
'full_name' => 'Mariano Iglesias' 'full_name' => 'Mariano Iglesias'
) )
); );
$result = $this->User->create($data); $result = $this->ValidateUser->create($data);
$this->assertTrue($result); $this->assertTrue($result);
$result = $this->User->validates(); $result = $this->ValidateUser->validates();
$this->assertFalse($result); $this->assertFalse($result);
$result = $this->User->Profile->validates(); $result = $this->ValidateUser->ValidateProfile->validates();
$this->assertFalse($result); $this->assertFalse($result);
$result = $this->Form->create('User', array('type' => 'post', 'action' => 'add')); $result = $this->Form->create('ValidateUser', array('type' => 'post', 'action' => 'add'));
$this->assertPattern('/^<form\s+id="[^"]+"\s+method="post"\s+action="\/users\/add\/"[^>]*>$/', $result); $this->assertPattern('/^<form\s+id="[^"]+"\s+method="post"\s+action="\/validate_users\/add\/"[^>]*>$/', $result);
$expected = array( $expected = array(
'User' => array( 'ValidateUser' => array(
'email' => 1 'email' => 1
), ),
'Profile' => array( 'ValidateProfile' => array(
'full_name' => 1, 'full_name' => 1,
'city' => 1 'city' => 1
) )
@ -313,52 +313,52 @@ class FormHelperTest extends CakeTestCase {
$this->assertEqual($this->Form->validationErrors, $expected); $this->assertEqual($this->Form->validationErrors, $expected);
unset($this->User->Profile); unset($this->ValidateUser->ValidateProfile);
unset($this->User); unset($this->ValidateUser);
} }
function testFormValidationAssociatedSecondLevel() { function testFormValidationAssociatedSecondLevel() {
$this->User =& new User(); $this->ValidateUser =& new ValidateUser();
$this->User->Profile =& new Profile(); $this->ValidateUser->ValidateProfile =& new ValidateProfile();
$this->User->Profile->Item =& new Item(); $this->ValidateUser->ValidateProfile->ValidateItem =& new ValidateItem();
$data = array( $data = array(
'User' => array( 'ValidateUser' => array(
'name' => 'mariano' 'name' => 'mariano'
), ),
'Profile' => array( 'ValidateProfile' => array(
'full_name' => 'Mariano Iglesias' 'full_name' => 'Mariano Iglesias'
), ),
'Item' => array( 'ValidateItem' => array(
'name' => 'Item' 'name' => 'Item'
) )
); );
$result = $this->User->create($data); $result = $this->ValidateUser->create($data);
$this->assertTrue($result); $this->assertTrue($result);
$result = $this->User->validates(); $result = $this->ValidateUser->validates();
$this->assertFalse($result); $this->assertFalse($result);
$result = $this->User->Profile->validates(); $result = $this->ValidateUser->ValidateProfile->validates();
$this->assertFalse($result); $this->assertFalse($result);
$result = $this->User->Profile->Item->validates(); $result = $this->ValidateUser->ValidateProfile->ValidateItem->validates();
$this->assertFalse($result); $this->assertFalse($result);
$result = $this->Form->create('User', array('type' => 'post', 'action' => 'add')); $result = $this->Form->create('ValidateUser', array('type' => 'post', 'action' => 'add'));
$this->assertPattern('/^<form\s+id="[^"]+"\s+method="post"\s+action="\/users\/add\/"[^>]*>$/', $result); $this->assertPattern('/^<form\s+id="[^"]+"\s+method="post"\s+action="\/validate_users\/add\/"[^>]*>$/', $result);
/* /*
$expected = array( $expected = array(
'User' => array( 'ValidateUser' => array(
'email' => 1 'email' => 1
), ),
'Profile' => array( 'ValidateProfile' => array(
'full_name' => 1, 'full_name' => 1,
'city' => 1 'city' => 1
), ),
'Item' => array( 'ValidateItem' => array(
'description' => 1 'description' => 1
) )
); );
@ -366,9 +366,9 @@ class FormHelperTest extends CakeTestCase {
$this->assertEqual($this->Form->validationErrors, $expected); $this->assertEqual($this->Form->validationErrors, $expected);
*/ */
unset($this->User->Profile->Item); unset($this->ValidateUser->ValidateProfile->ValidateItem);
unset($this->User->Profile); unset($this->ValidateUser->ValidateProfile);
unset($this->User); unset($this->ValidateUser);
} }
function testFormInput() { function testFormInput() {