Browse files

Adding tests for doAssociations

  • Loading branch information...
1 parent 6be70c3 commit ef519621b476f398ea65324384e837833a427b64 @markstory markstory committed May 10, 2009
Showing with 37 additions and 0 deletions.
  1. +37 −0 cake/tests/cases/console/libs/tasks/model.test.php
View
37 cake/tests/cases/console/libs/tasks/model.test.php
@@ -417,6 +417,36 @@ function testHasAndBelongsToManyGeneration() {
}
/**
+ * 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.
*
* @return void
@@ -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.