summaryrefslogtreecommitdiff
path: root/tests/unit/Data
diff options
context:
space:
mode:
authorknut <>2008-08-06 13:33:38 +0000
committerknut <>2008-08-06 13:33:38 +0000
commitbb60bcd2032e887e010904999655d2e5999e9878 (patch)
tree43bb4e7aa5e12d4781f6922d60211291f5b4c32c /tests/unit/Data
parentf7f3d150ef35c026bf6aee72e78362e263419e1a (diff)
fixed #899
Diffstat (limited to 'tests/unit/Data')
-rw-r--r--tests/unit/Data/DataGateway/AllTests.php28
-rw-r--r--tests/unit/Data/DataGateway/TSqlCriteriaTest.php111
2 files changed, 139 insertions, 0 deletions
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();
+ }
+
+}
+
+?>