$result=$this->_em->createQuery('SELECT m, m.salary+2500 AS add FROM Doctrine\Tests\Models\Company\CompanyManager m')
->getResult();
$this->assertEquals(4,count($result));
$this->assertEquals(102500, $result[0]['op']);
$this->assertEquals(202500, $result[1]['op']);
$this->assertEquals(402500, $result[2]['op']);
$this->assertEquals(802500, $result[3]['op']);
$this->assertEquals(102500,$result[0]['add']);
$this->assertEquals(202500,$result[1]['add']);
$this->assertEquals(402500,$result[2]['add']);
$this->assertEquals(802500,$result[3]['add']);
}
publicfunctiontestOperatorSub()
{
$result = $this->_em->createQuery('SELECT m, m.salary-2500 AS add FROM Doctrine\Tests\Models\Company\CompanyManager m')
$result=$this->_em->createQuery('SELECT m, m.salary-2500 AS sub FROM Doctrine\Tests\Models\Company\CompanyManager m')
->getResult();
$this->assertEquals(4,count($result));
$this->assertEquals(102500, $result[0]['op']);
$this->assertEquals(202500, $result[1]['op']);
$this->assertEquals(402500, $result[2]['op']);
$this->assertEquals(802500, $result[3]['op']);
$this->assertEquals(97500,$result[0]['sub']);
$this->assertEquals(197500,$result[1]['sub']);
$this->assertEquals(397500,$result[2]['sub']);
$this->assertEquals(797500,$result[3]['sub']);
}
publicfunctiontestOperatorMultiply()
...
...
@@ -243,6 +242,9 @@ class QueryDqlFunctionTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals(1600000,$result[3]['op']);
}
/**
* @group test
*/
publicfunctiontestOperatorDiv()
{
$result=$this->_em->createQuery('SELECT m, (m.salary/0.5) AS op FROM Doctrine\Tests\Models\Company\CompanyManager m')
...
...
@@ -253,7 +255,20 @@ class QueryDqlFunctionTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals(400000,$result[1]['op']);
$this->assertEquals(800000,$result[2]['op']);
$this->assertEquals(1600000,$result[3]['op']);
}*/
}
publicfunctiontestConcatFunction()
{
$arg=$this->_em->createQuery('SELECT CONCAT(m.name, m.department) AS namedep FROM Doctrine\Tests\Models\Company\CompanyManager m order by namedep desc')
@@ -534,4 +534,24 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
"SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ WHERE EXISTS (SELECT 1 FROM cms_addresses c1_ WHERE c1_.user_id = c0_.id AND c1_.id = ?)"
"SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u LEFT JOIN u.address a WHERE a.id IS NULL",
"SELECT c0_.id AS id0, c0_.status AS status1, c0_.username AS username2, c0_.name AS name3 FROM cms_users c0_ LEFT JOIN cms_addresses c1_ ON c0_.id = c1_.user_id WHERE c1_.id IS NULL"