From 02dcacc7aeb6abedbe52e320ea3f8624eab59bd2 Mon Sep 17 00:00:00 2001 From: "Jonathan.Wage" Date: Tue, 31 Jul 2007 20:42:36 +0000 Subject: [PATCH] Added new test for select expressions. --- tests/Query/SelectExpressionTestCase.php | 101 +++++++++++++++++++++++ tests/run.php | 2 + 2 files changed, 103 insertions(+) create mode 100644 tests/Query/SelectExpressionTestCase.php diff --git a/tests/Query/SelectExpressionTestCase.php b/tests/Query/SelectExpressionTestCase.php new file mode 100644 index 000000000..1219baf83 --- /dev/null +++ b/tests/Query/SelectExpressionTestCase.php @@ -0,0 +1,101 @@ +. + */ + +/** + * Doctrine_Query_SelectExpression_TestCase + * This test case is used for testing DQL SELECT expressions functionality + * + * @package Doctrine + * @author Konsta Vesterinen + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + * @version $Revision$ + */ +class Doctrine_Query_SelectExpression_TestCase extends Doctrine_UnitTestCase +{ + public function testAdditionExpression() + { + $query = new Doctrine_Query(); + $query->select('u.*, (u.id + u.id) addition'); + $query->from('User u'); + + try { + $users = $query->execute(); + } catch(Exception $e) { + $this->fail(); + } + } + + public function testSubtractionExpression() + { + $query = new Doctrine_Query(); + $query->select('u.*, (u.id - u.id) subtraction'); + $query->from('User u'); + + try { + $users = $query->execute(); + } catch(Exception $e) { + $this->fail(); + } + } + + public function testDivisionExpression() + { + $query = new Doctrine_Query(); + $query->select('u.*, (u.id/u.id) division'); + $query->from('User u'); + + try { + $users = $query->execute(); + } catch(Exception $e) { + $this->fail(); + } + } + + public function testMultiplicationExpression() + { + $query = new Doctrine_Query(); + $query->select('u.*, (u.id * u.id) multiplication'); + $query->from('User u'); + + try { + $users = $query->execute(); + } catch(Exception $e) { + $this->fail(); + } + } + + public function testOrderByExpression() + { + $query = new Doctrine_Query(); + $query->select('u.*, (u.id * u.id) multiplication'); + $query->from('User u'); + $query->orderby('multiplication asc'); + + try { + $users = $query->execute(); + } catch(Exception $e) { + $this->fail(); + } + } +} \ No newline at end of file diff --git a/tests/run.php b/tests/run.php index 47fb6659c..ec70639ff 100644 --- a/tests/run.php +++ b/tests/run.php @@ -323,6 +323,8 @@ $test->addTestCase(new Doctrine_Record_ZeroValues_TestCase()); $test->addTestCase(new Doctrine_Query_Cache_TestCase()); $test->addTestCase(new Doctrine_Cache_Apc_TestCase()); + +$test->addTestCase(new Doctrine_Query_SelectExpression_TestCase()); /** $test->addTestCase(new Doctrine_Cache_Memcache_TestCase());