Skip to content
Permalink
Browse files

Adding tests for doAssociations

  • Loading branch information...
markstory committed May 10, 2009
1 parent 6be70c3 commit ef519621b476f398ea65324384e837833a427b64
Showing with 37 additions and 0 deletions.
  1. +37 −0 cake/tests/cases/console/libs/tasks/model.test.php
@@ -416,6 +416,36 @@ function testHasAndBelongsToManyGeneration() {
$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.
*
@@ -448,6 +478,13 @@ function testConfirmAssociations() {
'className' => 'CategoryThread',
'foreignKey' => 'parent_id',
),
),
'belongsTo' => array(
array(
'alias' => 'User',
'className' => 'User',
'foreignKey' => 'user_id',
),
)
);
$model = new Model(array('ds' => 'test_suite', 'name' => 'CategoryThread'));

0 comments on commit ef51962

Please sign in to comment.
You can’t perform that action at this time.