1
0
mirror of synced 2025-01-18 14:31:40 +03:00

Adding tests that confirm that DDC-2844 is fixed

This commit is contained in:
Marco Pivetta 2013-12-14 11:39:33 +01:00
parent 8a38534be4
commit 72e6de9417

View File

@ -422,6 +422,40 @@ class QueryBuilderTest extends \Doctrine\Tests\OrmTestCase
$this->assertNotNull($qb->getParameter('field_1')); $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() public function testAddCriteriaOrder()
{ {
$qb = $this->_em->createQueryBuilder(); $qb = $this->_em->createQueryBuilder();