/**
* @test
*/
public function itShouldBeAbleToDoAnAddWithMultipleJoins()
{
$this->query->setTable('user');
for ($i = 1; $i <= 5; ++$i) {
//Select QueryInterface for "news" table
$select = new Select();
$select->setTable('news' . $i)->setColumns(array('title' . $i));
//Select query for user table, being joined with "newsX" select.
$this->query->addJoin($select, 'user_id', 'author_id' . $i);
}
$expected = 'SELECT user.*, news1.title1, news2.title2, news3.title3, news4.title4, news5.title5 ' . 'FROM user JOIN news1 ON (news1.author_id1 = user.user_id) JOIN news2 ON (news2.author_id2 = user.user_id)' . ' JOIN news3 ON (news3.author_id3 = user.user_id) JOIN news4 ON (news4.author_id4 = user.user_id) ' . 'JOIN news5 ON (news5.author_id5 = user.user_id)';
$this->assertSame($expected, $this->writer->write($this->query));
}