1
0
mirror of synced 2025-03-23 08:23:51 +03:00

Merge pull request #875 from doctrine/DDC-2844

Adding tests that confirm that DDC-2844 is fixed
This commit is contained in:
Marco Pivetta 2013-12-14 05:13:24 -08:00
commit ce914bef3f

View File

@ -422,6 +422,74 @@ 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());
}
/**
* @group DDC-2844
*/
public function testAddCriteriaWhereWithMultipleParametersWithSubpathsAndDifferentProperties()
{
$qb = $this->_em->createQueryBuilder();
$criteria = new Criteria();
$criteria->where($criteria->expr()->eq('alias1.field1', 'value1'));
$criteria->andWhere($criteria->expr()->gt('alias1.field2', 'value2'));
$qb->addCriteria($criteria);
$this->assertEquals('alias1.field1 = :alias1_field1 AND alias1.field2 > :alias1_field2', (string) $qb->getDQLPart('where'));
$this->assertSame('value1', $qb->getParameter('alias1_field1')->getValue());
$this->assertSame('value2', $qb->getParameter('alias1_field2')->getValue());
}
/**
* @group DDC-2844
*/
public function testAddCriteriaWhereWithMultipleParametersWithSubpathsAndSameProperty()
{
$qb = $this->_em->createQueryBuilder();
$criteria = new Criteria();
$criteria->where($criteria->expr()->eq('alias1.field1', 'value1'));
$criteria->andWhere($criteria->expr()->gt('alias1.field1', 'value2'));
$qb->addCriteria($criteria);
$this->assertEquals('alias1.field1 = :alias1_field1 AND alias1.field1 > :alias1_field1_1', (string) $qb->getDQLPart('where'));
$this->assertSame('value1', $qb->getParameter('alias1_field1')->getValue());
$this->assertSame('value2', $qb->getParameter('alias1_field1_1')->getValue());
}
public function testAddCriteriaOrder()
{
$qb = $this->_em->createQueryBuilder();