Permalink
Browse files

Add test for ModelCriteria to prove it support IN operator in JOIN co…

…nditions
  • Loading branch information...
1 parent 80179d6 commit cb913c3601ce8b98baca577e39d72dc30b1e3fd6 @arvenil committed Mar 26, 2013
Showing with 24 additions and 0 deletions.
  1. +24 −0 test/testsuite/runtime/query/ModelCriteriaTest.php
@@ -939,6 +939,30 @@ public function testAddJoinConditionSimple()
$this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'addJoinCondition() allows the use of custom conditions');
}
+ public function testAddJoinConditionWithInOperator()
+ {
+ $con = Propel::getConnection(BookPeer::DATABASE_NAME);
+ $c = new ModelCriteria('bookstore', 'Author');
+ $c->join('Author.Book', Criteria::LEFT_JOIN);
+ $c->addJoinCondition('Book', 'Book.isbn IN ?', array(1, 7, 42));
+ $c->limit(1);
+ $books = AuthorPeer::doSelect($c, $con);
+ $expectedSQL = "SELECT author.id, author.first_name, author.last_name, author.email, author.age FROM `author` LEFT JOIN `book` ON (author.id=book.author_id AND book.isbn IN (1,7,42)) LIMIT 1";
+ $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'addJoinCondition() allows the use of custom conditions');
+ }
+
+ public function testAddJoinConditionWithNotInOperator()
+ {
+ $con = Propel::getConnection(BookPeer::DATABASE_NAME);
+ $c = new ModelCriteria('bookstore', 'Author');
+ $c->join('Author.Book', Criteria::LEFT_JOIN);
+ $c->addJoinCondition('Book', 'Book.isbn NOT IN ?', array(1, 7, 42));
+ $c->limit(1);
+ $books = AuthorPeer::doSelect($c, $con);
+ $expectedSQL = "SELECT author.id, author.first_name, author.last_name, author.email, author.age FROM `author` LEFT JOIN `book` ON (author.id=book.author_id AND book.isbn NOT IN (1,7,42)) LIMIT 1";
+ $this->assertEquals($expectedSQL, $con->getLastExecutedQuery(), 'addJoinCondition() allows the use of custom conditions');
+ }
+
public function testAddJoinConditionBinding()
{
$con = Propel::getConnection(BookPeer::DATABASE_NAME);

0 comments on commit cb913c3

Please sign in to comment.