Commit 3c5b98f7 by Klimov Paul

Unit test for issue #4018 added

parent bf599b96
......@@ -18,6 +18,11 @@ class ArticleIndex extends ActiveRecord
return $this->hasOne(ArticleDb::className(), ['id' => 'id']);
}
public function getSourceCompositeLink()
{
return $this->hasOne(ArticleDb::className(), ['id' => 'id', 'author_id' => 'author_id']);
}
public function getTags()
{
return $this->hasMany(TagDb::className(), ['id' => 'tag']);
......
......@@ -42,4 +42,17 @@ class ActiveRelationTest extends SphinxTestCase
$this->assertTrue($articles[0]->index instanceof ArticleIndex);
$this->assertTrue($articles[1]->index instanceof ArticleIndex);
}
/**
* @see https://github.com/yiisoft/yii2/issues/4018
*/
public function testFindCompositeLink()
{
$articles = ArticleIndex::find()->with('sourceCompositeLink')->all();
$this->assertEquals(2, count($articles));
$this->assertTrue($articles[0]->isRelationPopulated('sourceCompositeLink'));
$this->assertNotEmpty($articles[0]->sourceCompositeLink);
$this->assertTrue($articles[1]->isRelationPopulated('sourceCompositeLink'));
$this->assertNotEmpty($articles[1]->sourceCompositeLink);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment