From d197c814f39536c2c76f6ec9b0e154dabb1eab3e Mon Sep 17 00:00:00 2001 From: beberlei Date: Thu, 11 Feb 2010 19:14:45 +0000 Subject: [PATCH] [2.0] DDC-318 - Committed 3 commented tests for Operators that fail however --- .../ORM/Functional/QueryDqlFunctionTest.php | 60 +++++++++++++++++-- 1 file changed, 54 insertions(+), 6 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php b/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php index f0ed7e555..9f8a13d61 100644 --- a/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php @@ -63,14 +63,14 @@ class QueryDqlFunctionTest extends \Doctrine\Tests\OrmFunctionalTestCase public function testFunctionAbs() { - $arg = $this->_em->createQuery('SELECT m, ABS(m.salary * -1) AS abs FROM Doctrine\Tests\Models\Company\CompanyManager m') + $result = $this->_em->createQuery('SELECT m, ABS(m.salary * -1) AS abs FROM Doctrine\Tests\Models\Company\CompanyManager m') ->getResult(); - $this->assertEquals(4, count($arg)); - $this->assertEquals(100000, $arg[0]['abs']); - $this->assertEquals(200000, $arg[1]['abs']); - $this->assertEquals(400000, $arg[2]['abs']); - $this->assertEquals(800000, $arg[3]['abs']); + $this->assertEquals(4, count($result)); + $this->assertEquals(100000, $result[0]['abs']); + $this->assertEquals(200000, $result[1]['abs']); + $this->assertEquals(400000, $result[2]['abs']); + $this->assertEquals(800000, $result[3]['abs']); } public function testFunctionConcat() @@ -203,6 +203,54 @@ class QueryDqlFunctionTest extends \Doctrine\Tests\OrmFunctionalTestCase $this->assertEquals('Jonathan W.', $result[3]['str3']); } + /*public function testOperatorAdd() + { + $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']); + } + + public function testOperatorSub() + { + $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']); + } + + public function testOperatorMultiply() + { + $result = $this->_em->createQuery('SELECT m, m.salary*2 AS op FROM Doctrine\Tests\Models\Company\CompanyManager m') + ->getResult(); + + $this->assertEquals(4, count($result)); + $this->assertEquals(200000, $result[0]['op']); + $this->assertEquals(400000, $result[1]['op']); + $this->assertEquals(800000, $result[2]['op']); + $this->assertEquals(1600000, $result[3]['op']); + } + + public function testOperatorDiv() + { + $result = $this->_em->createQuery('SELECT m, (m.salary/0.5) AS op FROM Doctrine\Tests\Models\Company\CompanyManager m') + ->getResult(); + + $this->assertEquals(4, count($result)); + $this->assertEquals(200000, $result[0]['op']); + $this->assertEquals(400000, $result[1]['op']); + $this->assertEquals(800000, $result[2]['op']); + $this->assertEquals(1600000, $result[3]['op']); + }*/ + protected function generateFixture() { $manager1 = new CompanyManager();