Permalink
Browse files

regression test for DBAL-172

  • Loading branch information...
1 parent 70cb967 commit edf2843869f64e6e7ea1398fc37f64a3b31e9fee Wim Vandersmissen committed Sep 12, 2012
Showing with 18 additions and 0 deletions.
  1. +18 −0 tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php
@@ -566,4 +566,22 @@ public function testReferenceJoinFromJoin()
$this->setExpectedException('Doctrine\DBAL\Query\QueryException', "The given alias 'invalid' is not part of any FROM or JOIN clause table. The currently registered aliases are: news, nv, nt, n.");
$this->assertEquals('', $qb->getSQL());
}
+
+ /**
+ * @group DBAL-172
+ */
+ public function testSelectFromMasterWithWhereOnJoinedTables()
+ {
+ $qb = new QueryBuilder($this->conn);
+
+ $qb->select('COUNT(DISTINCT news.id)')
+ ->from('newspages', 'news')
+ ->innerJoin('news', 'nodeversion', 'nv', "nv.refId = news.id AND nv.refEntityname='Entity\\News'")
+ ->innerJoin('nv', 'nodetranslation', 'nt', 'nv.nodetranslation = nt.id')
+ ->innerJoin('nt', 'node', 'n', 'nt.node = n.id')
+ ->where('nt.lang = ?')
+ ->andWhere('n.deleted = 0');
+
+ $this->assertEquals("SELECT COUNT(DISTINCT news.id) FROM newspages news INNER JOIN nodeversion nv ON nv.refId = news.id AND nv.refEntityname='Entity\\News' INNER JOIN nodetranslation nt ON nv.nodetranslation = nt.id INNER JOIN node n ON nt.node = n.id WHERE (nt.lang = ?) AND (n.deleted = 0)", $qb->getSQL());
+ }
}

0 comments on commit edf2843

Please sign in to comment.