From a03d7c6cd56c8b7a5a5c4a1614efd3d0e125f6c6 Mon Sep 17 00:00:00 2001 From: zYne Date: Fri, 23 Mar 2007 20:26:25 +0000 Subject: [PATCH] some tests for CHECK constraint parser --- tests/Query/CheckTestCase.php | 69 +++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 tests/Query/CheckTestCase.php diff --git a/tests/Query/CheckTestCase.php b/tests/Query/CheckTestCase.php new file mode 100644 index 000000000..76023af6a --- /dev/null +++ b/tests/Query/CheckTestCase.php @@ -0,0 +1,69 @@ +. + */ + +/** + * Doctrine_Query_Check_TestCase + * + * @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_Check_TestCase extends Doctrine_UnitTestCase +{ + public function prepareData() + { } + public function prepareTables() + { } + public function testCheckParserSupportsStandardFunctions() + { + $q = new Doctrine_Query_Check('User'); + + $q->parse('LENGTH(name) > 6'); + + $this->assertEqual($q->getSql(), 'LENGTH(name) > 6'); + } + public function testCheckParserThrowsExceptionForUnknownOperator() + { + $q = new Doctrine_Query_Check('User'); + + try { + $q->parse('LENGTH(name) ? 6'); + $this->fail(); + } catch(Doctrine_Query_Exception $e) { + $this->pass(); + } + } + public function testCheckParserThrowsExceptionForUnknownFunction() + { + $q = new Doctrine_Query_Check('User'); + + try { + $q->parse('SomeUnknownFunction(name) = 6'); + $this->fail(); + } catch(Doctrine_Exception $e) { + $this->pass(); + } + } +}