Get the array of associations to generate.
public getAssociations ( |
||
$table | The table to get associations for. | |
Результат | array |
/** * Test getAssociations in a plugin * * @return void */ public function testGetAssociationsPlugin() { $articles = TableRegistry::get('BakeArticles'); $this->Task->plugin = 'TestBake'; $result = $this->Task->getAssociations($articles); $expected = ['belongsTo' => [['alias' => 'BakeUsers', 'className' => 'TestBake.BakeUsers', 'foreignKey' => 'bake_user_id', 'joinType' => 'INNER']], 'hasMany' => [['alias' => 'BakeComments', 'className' => 'TestBake.BakeComments', 'foreignKey' => 'bake_article_id']], 'belongsToMany' => [['alias' => 'BakeTags', 'className' => 'TestBake.BakeTags', 'foreignKey' => 'bake_article_id', 'joinTable' => 'bake_articles_bake_tags', 'targetForeignKey' => 'bake_tag_id']]]; $this->assertEquals($expected, $result); }