mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-18 23:49:55 +00:00
Adding tests for doAssociations
This commit is contained in:
parent
6be70c3cfa
commit
ef519621b4
1 changed files with 37 additions and 0 deletions
|
@ -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'));
|
||||||
|
|
Loading…
Add table
Reference in a new issue