Skip to content

Commit

Permalink
Adding tests for doAssociations
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed May 10, 2009
1 parent 6be70c3 commit ef51962
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions cake/tests/cases/console/libs/tasks/model.test.php
Expand Up @@ -416,6 +416,36 @@ function testHasAndBelongsToManyGeneration() {
$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.
* *
Expand Down Expand Up @@ -448,6 +478,13 @@ function testConfirmAssociations() {
'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'));
Expand Down

0 comments on commit ef51962

Please sign in to comment.