diff --git a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php index 98c3e2bc5..f3c45c9af 100644 --- a/tests/Doctrine/Tests/ORM/QueryBuilderTest.php +++ b/tests/Doctrine/Tests/ORM/QueryBuilderTest.php @@ -422,6 +422,40 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase $this->assertNotNull($qb->getParameter('field_1')); } + /** + * @group DDC-2844 + */ + public function testAddCriteriaWhereWithMultipleParametersWithSameField() + { + $qb = $this->_em->createQueryBuilder(); + $criteria = new Criteria(); + $criteria->where($criteria->expr()->eq('field', 'value1')); + $criteria->andWhere($criteria->expr()->gt('field', 'value2')); + + $qb->addCriteria($criteria); + + $this->assertEquals('field = :field AND field > :field_1', (string) $qb->getDQLPart('where')); + $this->assertSame('value1', $qb->getParameter('field')->getValue()); + $this->assertSame('value2', $qb->getParameter('field_1')->getValue()); + } + + /** + * @group DDC-2844 + */ + public function testAddCriteriaWhereWithMultipleParametersWithDifferentFields() + { + $qb = $this->_em->createQueryBuilder(); + $criteria = new Criteria(); + $criteria->where($criteria->expr()->eq('field1', 'value1')); + $criteria->andWhere($criteria->expr()->gt('field2', 'value2')); + + $qb->addCriteria($criteria); + + $this->assertEquals('field1 = :field1 AND field2 > :field2', (string) $qb->getDQLPart('where')); + $this->assertSame('value1', $qb->getParameter('field1')->getValue()); + $this->assertSame('value2', $qb->getParameter('field2')->getValue()); + } + public function testAddCriteriaOrder() { $qb = $this->_em->createQueryBuilder();