Adding tests for doAssociations

This commit is contained in:
mark_story 2009-05-10 12:11:20 -04:00
parent 6be70c3cfa
commit ef519621b4

View file

@ -416,6 +416,36 @@ class ModelTaskTest extends CakeTestCase {
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
} }
/**
* test non interactive doAssociations
*
* @return void
**/
function testDoAssociationsNonInteractive() {
$this->Task->connection = 'test_suite';
$this->Task->interactive = false;
$model = new Model(array('ds' => 'test_suite', 'name' => 'Article'));
$result = $this->Task->doAssociations($model);
$expected = array(
'hasMany' => array(
array(
'alias' => 'Comment',
'className' => 'Comment',
'foreignKey' => 'article_id',
),
),
'hasAndBelongsToMany' => array(
array(
'alias' => 'Tag',
'className' => 'Tag',
'foreignKey' => 'article_id',
'joinTable' => 'articles_tags',
'associationForeignKey' => 'tag_id',
),
),
);
}
/** /**
* Ensure that the fixutre object is correctly called. * Ensure that the fixutre object is correctly called.
* *
@ -448,6 +478,13 @@ class ModelTaskTest extends CakeTestCase {
'className' => 'CategoryThread', 'className' => 'CategoryThread',
'foreignKey' => 'parent_id', 'foreignKey' => 'parent_id',
), ),
),
'belongsTo' => array(
array(
'alias' => 'User',
'className' => 'User',
'foreignKey' => 'user_id',
),
) )
); );
$model = new Model(array('ds' => 'test_suite', 'name' => 'CategoryThread')); $model = new Model(array('ds' => 'test_suite', 'name' => 'CategoryThread'));