Find the hasMany relations and add them to associations list
public findHasMany ( |
||
$model | Model instance being generated | |
$associations | array | Array of in progress associations |
return | array | Associations with hasMany added in. |
/** * test that hasOne and/or hasMany relations are generated properly. * * @return void */ public function testHasManyGeneration() { $this->Task->connection = 'test'; $model = TableRegistry::get('BakeArticles'); $result = $this->Task->findHasMany($model, []); $expected = ['hasMany' => [['alias' => 'BakeComments', 'foreignKey' => 'bake_article_id']]]; $this->assertEquals($expected, $result); $model = TableRegistry::get('CategoryThreads'); $result = $this->Task->findHasMany($model, []); $expected = ['hasMany' => [['alias' => 'ChildCategoryThreads', 'className' => 'CategoryThreads', 'foreignKey' => 'parent_id']]]; $this->assertEquals($expected, $result); $this->Task->plugin = 'Blog'; $result = $this->Task->findHasMany($model, []); $expected = ['hasMany' => [['alias' => 'ChildCategoryThreads', 'className' => 'Blog.CategoryThreads', 'foreignKey' => 'parent_id']]]; $this->assertEquals($expected, $result); }