diff options
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/AllTests.php | 2 | ||||
-rw-r--r-- | tests/unit/Data/DataGateway/AllTests.php | 28 | ||||
-rw-r--r-- | tests/unit/Data/DataGateway/TSqlCriteriaTest.php | 111 |
3 files changed, 141 insertions, 0 deletions
diff --git a/tests/unit/AllTests.php b/tests/unit/AllTests.php index bbd53a66..220b9366 100644 --- a/tests/unit/AllTests.php +++ b/tests/unit/AllTests.php @@ -15,6 +15,7 @@ require_once 'Web/UI/ActiveControls/AllTests.php'; require_once 'Security/AllTests.php'; require_once 'Caching/AllTests.php'; require_once 'Util/AllTests.php'; +require_once 'Data/DataGateway/AllTests.php'; require_once 'TComponentTest.php'; @@ -36,6 +37,7 @@ class AllTests { $suite->addTest(Security_AllTests::suite()); $suite->addTest(Caching_AllTests::suite()); $suite->addTest(Util_AllTests::suite()); + $suite->addTest(Data_DataGateway_AllTests::suite()); $suite->addTestSuite('TComponentTest'); diff --git a/tests/unit/Data/DataGateway/AllTests.php b/tests/unit/Data/DataGateway/AllTests.php new file mode 100644 index 00000000..f3405613 --- /dev/null +++ b/tests/unit/Data/DataGateway/AllTests.php @@ -0,0 +1,28 @@ +<?php +require_once dirname(__FILE__).'/../../phpunit.php'; + +if(!defined('PHPUnit_MAIN_METHOD')) { + define('PHPUnit_MAIN_METHOD', 'Data_DataGateway_AllTests::main'); +} + +require_once 'TSqlCriteriaTest.php'; + +class Data_DataGateway_AllTests { + + public static function main() { + PHPUnit_TextUI_TestRunner::run(self::suite()); + } + + public static function suite() { + $suite = new PHPUnit_Framework_TestSuite('System.Data.DataGateway'); + + $suite->addTestSuite('TSqlCriteriaTest'); + + return $suite; + } +} + +if(PHPUnit_MAIN_METHOD == 'Data_DataGateway_AllTests::main') { + Data_DataGateway_AllTests::main(); +} +?> diff --git a/tests/unit/Data/DataGateway/TSqlCriteriaTest.php b/tests/unit/Data/DataGateway/TSqlCriteriaTest.php new file mode 100644 index 00000000..043520e7 --- /dev/null +++ b/tests/unit/Data/DataGateway/TSqlCriteriaTest.php @@ -0,0 +1,111 @@ +<?php +require_once dirname(__FILE__).'/../../phpunit.php'; + +Prado::using('System.Data.DataGateway.TSqlCriteria'); + +/** + * @package System.Data.DataGateway + */ +class TSqlCriteriaTest extends PHPUnit_Framework_TestCase { + + public function setUp() { + } + + public function tearDown() { + } + + public function testConstruct() { + throw new PHPUnit_Framework_IncompleteTestError(); + } + + public function testConditionWithOrderByColumnNames() { + $criteria = new TSqlCriteria(); + $criteria->Condition = "SELECT * FROM table_references ORDER BY field1 ASC, field2 DESC"; + self::assertEquals("SELECT * FROM table_references", $criteria->Condition); + self::assertEquals(true, isset($criteria->OrdersBy['field1'])); + self::assertEquals('ASC', $criteria->OrdersBy['field1']); + self::assertEquals(true, isset($criteria->OrdersBy['field2'])); + self::assertEquals('DESC', $criteria->OrdersBy['field2']); + } + + public function testConditionWithOrderByExpression() { + $criteria = new TSqlCriteria(); + $criteria->Condition = "SELECT * FROM table_references ORDER BY RAND()"; + self::assertEquals("SELECT * FROM table_references", $criteria->Condition); + self::assertEquals(true, isset($criteria->OrdersBy['RAND()'])); + self::assertEquals('asc', $criteria->OrdersBy['RAND()']); + } + + public function testConditionWithOrderByAndLimit() { + $criteria = new TSqlCriteria(); + $criteria->Condition = "SELECT * FROM table_references ORDER BY field1 ASC, field2 DESC LIMIT 2"; + self::assertEquals("SELECT * FROM table_references", $criteria->Condition); + self::assertEquals(2, $criteria->Limit); + } + + public function testConditionWithOrderByAndLimitAndOffset() { + $criteria = new TSqlCriteria(); + $criteria->Condition = "SELECT * FROM table_references ORDER BY field1 ASC, field2 DESC LIMIT 3, 2"; + self::assertEquals("SELECT * FROM table_references", $criteria->Condition); + self::assertEquals(2, $criteria->Limit); + self::assertEquals(3, $criteria->Offset); + } + + public function testConditionWithOrderByAndLimitAndOffsetVariant() { + $criteria = new TSqlCriteria(); + $criteria->Condition = "SELECT * FROM table_references ORDER BY field1 ASC, field2 DESC LIMIT 2 OFFSET 3"; + self::assertEquals("SELECT * FROM table_references", $criteria->Condition); + self::assertEquals(2, $criteria->Limit); + self::assertEquals(3, $criteria->Offset); + } + + public function testConditionWithLimit() { + $criteria = new TSqlCriteria(); + $criteria->Condition = "SELECT * FROM table_references LIMIT 2"; + self::assertEquals("SELECT * FROM table_references", $criteria->Condition); + self::assertEquals(2, $criteria->Limit); + } + + public function testConditionWithLimitAndOffset() { + $criteria = new TSqlCriteria(); + $criteria->Condition = "SELECT * FROM table_references LIMIT 3, 2"; + self::assertEquals("SELECT * FROM table_references", $criteria->Condition); + self::assertEquals(2, $criteria->Limit); + self::assertEquals(3, $criteria->Offset); + } + + public function testConditionWithLimitAndOffsetVariant() { + $criteria = new TSqlCriteria(); + $criteria->Condition = "SELECT * FROM table_references LIMIT 2 OFFSET 3"; + self::assertEquals("SELECT * FROM table_references", $criteria->Condition); + self::assertEquals(2, $criteria->Limit); + self::assertEquals(3, $criteria->Offset); + } + + public function testParameters() { + throw new PHPUnit_Framework_IncompleteTestError(); + } + + public function testIsNamedParameters() { + throw new PHPUnit_Framework_IncompleteTestError(); + } + + public function testOrdersBy() { + throw new PHPUnit_Framework_IncompleteTestError(); + } + + public function testLimit() { + throw new PHPUnit_Framework_IncompleteTestError(); + } + + public function testOffset() { + throw new PHPUnit_Framework_IncompleteTestError(); + } + + public function testToString() { + throw new PHPUnit_Framework_IncompleteTestError(); + } + +} + +?> |