1
0
mirror of synced 2025-01-18 06:21:40 +03:00

test case expression

This commit is contained in:
Fabio B. Silva 2012-08-11 16:37:09 -03:00
parent f0403a5394
commit 6844116b94

View File

@ -129,7 +129,7 @@ class NewOperatorTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals($this->fixtures[2]->address->city, $result[2]->address);
}
public function testShouldSupportLiteral()
public function testShouldSupportLiteralExpression()
{
$dql = "
SELECT
@ -179,6 +179,46 @@ class NewOperatorTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals(123, $result[2]->phonenumbers);
}
public function testShouldSupportCaseExpression()
{
$dql = "
SELECT
new Doctrine\Tests\Models\CMS\CmsUserDTO(
u.name,
CASE WHEN (e.email = 'email@test1.com') THEN 'TEST1' ELSE 'OTHER_TEST' END
)
FROM
Doctrine\Tests\Models\CMS\CmsUser u
JOIN
u.email e
JOIN
u.address a
JOIN
u.phonenumbers p
GROUP BY
u, e, a
ORDER BY
u.name";
$query = $this->_em->createQuery($dql);
$result = $query->getResult();
$this->assertCount(3, $result);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUserDTO', $result[2]);
$this->assertEquals($this->fixtures[0]->name, $result[0]->name);
$this->assertEquals($this->fixtures[1]->name, $result[1]->name);
$this->assertEquals($this->fixtures[2]->name, $result[2]->name);
$this->assertEquals('TEST1', $result[0]->email);
$this->assertEquals('OTHER_TEST', $result[1]->email);
$this->assertEquals('OTHER_TEST', $result[2]->email);
}
public function testShouldSupportSimpleArithmeticExpression()
{
$dql = "