test case expression
This commit is contained in:
parent
f0403a5394
commit
6844116b94
@ -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 = "
|
||||
|
Loading…
x
Reference in New Issue
Block a user