summaryrefslogtreecommitdiff
path: root/tests/simple_unit/DbCommon
diff options
context:
space:
mode:
authorwei <>2007-04-12 12:43:49 +0000
committerwei <>2007-04-12 12:43:49 +0000
commit32b73a0b1dfcd33e07e7fd2b2cf2fd7d42cf48a0 (patch)
treebf2b348fa854d82dcf8a9f43ffd43df3eba5a1e8 /tests/simple_unit/DbCommon
parent815ce4bcc616c4b0618046651174062efc93fd06 (diff)
Add Sqlite driver.
Diffstat (limited to 'tests/simple_unit/DbCommon')
-rw-r--r--tests/simple_unit/DbCommon/CommandBuilderPgsqlTest.php9
-rw-r--r--tests/simple_unit/DbCommon/MysqlColumnTest.php15
-rw-r--r--tests/simple_unit/DbCommon/PgsqlColumnTest.php8
-rw-r--r--tests/simple_unit/DbCommon/SqliteColumnTest.php30
4 files changed, 34 insertions, 28 deletions
diff --git a/tests/simple_unit/DbCommon/CommandBuilderPgsqlTest.php b/tests/simple_unit/DbCommon/CommandBuilderPgsqlTest.php
index 8bf2848e..9ee9c411 100644
--- a/tests/simple_unit/DbCommon/CommandBuilderPgsqlTest.php
+++ b/tests/simple_unit/DbCommon/CommandBuilderPgsqlTest.php
@@ -1,5 +1,4 @@
-<?php
-
+<?php
Prado::using('System.Data.*');
Prado::using('System.Data.Common.Pgsql.TPgsqlMetaData');
@@ -60,15 +59,15 @@ class CommandBuilderPgsqlTest extends UnitTestCase
$builder = $meta->createCommandBuilder('address');
$query = 'SELECT * FROM '.$meta->getTableInfo('address')->getTableFullName();
- $limit = $builder->createLimitCondition($query, 1);
+ $limit = $builder->applyLimitOffset($query, 1);
$expect = $query.' LIMIT 1';
$this->assertEqual($expect, $limit);
- $limit = $builder->createLimitCondition($query, -1, 10);
+ $limit = $builder->applyLimitOffset($query, -1, 10);
$expect = $query.' OFFSET 10';
$this->assertEqual($expect, $limit);
- $limit = $builder->createLimitCondition($query, 2, 3);
+ $limit = $builder->applyLimitOffset($query, 2, 3);
$expect = $query.' LIMIT 2 OFFSET 3';
$this->assertEqual($expect, $limit);
}
diff --git a/tests/simple_unit/DbCommon/MysqlColumnTest.php b/tests/simple_unit/DbCommon/MysqlColumnTest.php
index d8bb8194..17eb6063 100644
--- a/tests/simple_unit/DbCommon/MysqlColumnTest.php
+++ b/tests/simple_unit/DbCommon/MysqlColumnTest.php
@@ -27,7 +27,6 @@ class MysqlColumnTest extends UnitTestCase
'NumericScale' => null,
'IsPrimaryKey' => true,
'IsForeignKey' => false,
- 'IsUnique' => false,
'SequenceName' => null,
'AutoIncrement' => true,
);
@@ -43,7 +42,6 @@ class MysqlColumnTest extends UnitTestCase
'NumericScale' => null,
'IsPrimaryKey' => true,
'IsForeignKey' => false,
- 'IsUnique' => false,
'SequenceName' => null,
'AutoIncrement' => false,
);
@@ -59,7 +57,6 @@ class MysqlColumnTest extends UnitTestCase
'NumericScale' => null,
'IsPrimaryKey' => false,
'IsForeignKey' => false,
- 'IsUnique' => false,
'SequenceName' => null,
'AutoIncrement' => false,
);
@@ -75,7 +72,6 @@ class MysqlColumnTest extends UnitTestCase
'NumericScale' => null,
'IsPrimaryKey' => false,
'IsForeignKey' => false,
- 'IsUnique' => false,
'SequenceName' => null,
'AutoIncrement' => false,
);
@@ -91,7 +87,6 @@ class MysqlColumnTest extends UnitTestCase
'NumericScale' => null,
'IsPrimaryKey' => false,
'IsForeignKey' => false,
- 'IsUnique' => false,
'SequenceName' => null,
'AutoIncrement' => false,
);
@@ -107,7 +102,6 @@ class MysqlColumnTest extends UnitTestCase
'NumericScale' => null,
'IsPrimaryKey' => false,
'IsForeignKey' => false,
- 'IsUnique' => false,
'SequenceName' => null,
'AutoIncrement' => false,
);
@@ -123,7 +117,6 @@ class MysqlColumnTest extends UnitTestCase
'NumericScale' => 4,
'IsPrimaryKey' => false,
'IsForeignKey' => false,
- 'IsUnique' => false,
'SequenceName' => null,
'AutoIncrement' => false,
);
@@ -139,7 +132,6 @@ class MysqlColumnTest extends UnitTestCase
'NumericScale' => null,
'IsPrimaryKey' => false,
'IsForeignKey' => false,
- 'IsUnique' => false,
'SequenceName' => null,
'AutoIncrement' => false,
);
@@ -155,7 +147,6 @@ class MysqlColumnTest extends UnitTestCase
'NumericScale' => null,
'IsPrimaryKey' => false,
'IsForeignKey' => false,
- 'IsUnique' => false,
'SequenceName' => null,
'AutoIncrement' => false,
);
@@ -171,7 +162,6 @@ class MysqlColumnTest extends UnitTestCase
'NumericScale' => null,
'IsPrimaryKey' => false,
'IsForeignKey' => false,
- 'IsUnique' => false,
'SequenceName' => null,
'AutoIncrement' => false,
);
@@ -187,7 +177,6 @@ class MysqlColumnTest extends UnitTestCase
'NumericScale' => null,
'IsPrimaryKey' => false,
'IsForeignKey' => false,
- 'IsUnique' => false,
'SequenceName' => null,
'AutoIncrement' => false,
);
@@ -203,7 +192,6 @@ class MysqlColumnTest extends UnitTestCase
'NumericScale' => null,
'IsPrimaryKey' => false,
'IsForeignKey' => false,
- 'IsUnique' => false,
'SequenceName' => null,
'AutoIncrement' => false,
);
@@ -219,7 +207,6 @@ class MysqlColumnTest extends UnitTestCase
'NumericScale' => null,
'IsPrimaryKey' => false,
'IsForeignKey' => false,
- 'IsUnique' => false,
'SequenceName' => null,
'AutoIncrement' => false,
'DbTypeValues' => array('one', 'two', 'three'),
@@ -236,7 +223,6 @@ class MysqlColumnTest extends UnitTestCase
'NumericScale' => null,
'IsPrimaryKey' => false,
'IsForeignKey' => false,
- 'IsUnique' => false,
'SequenceName' => null,
'AutoIncrement' => false,
'DbTypeValues' => array('blue', 'red', 'green'),
@@ -247,7 +233,6 @@ class MysqlColumnTest extends UnitTestCase
$this->assertNull($table->getSchemaName());
$this->assertEqual('table1', $table->getTableName());
$this->assertEqual(array('id', 'name'), $table->getPrimaryKeys());
- $this->assertEqual(array('fk3'), $table->getUniqueKeys());
}
function assertColumn($columns, $table)
diff --git a/tests/simple_unit/DbCommon/PgsqlColumnTest.php b/tests/simple_unit/DbCommon/PgsqlColumnTest.php
index 0f633725..de12083e 100644
--- a/tests/simple_unit/DbCommon/PgsqlColumnTest.php
+++ b/tests/simple_unit/DbCommon/PgsqlColumnTest.php
@@ -26,7 +26,6 @@ class PgsqlColumnTest extends UnitTestCase
'NumericScale' => null,
'IsPrimaryKey' => true,
'IsForeignKey' => false,
- 'IsUnique' => false,
'SequenceName' => 'public.address_id_seq',
);
@@ -41,7 +40,6 @@ class PgsqlColumnTest extends UnitTestCase
'NumericScale' => null,
'IsPrimaryKey' => false,
'IsForeignKey' => false,
- 'IsUnique' => true,
'SequenceName' => null,
);
@@ -56,7 +54,6 @@ class PgsqlColumnTest extends UnitTestCase
'NumericScale' => null,
'IsPrimaryKey' => false,
'IsForeignKey' => false,
- 'IsUnique' => true,
'SequenceName' => null,
);
@@ -71,7 +68,6 @@ class PgsqlColumnTest extends UnitTestCase
'NumericScale' => null,
'IsPrimaryKey' => false,
'IsForeignKey' => false,
- 'IsUnique' => false,
'SequenceName' => null,
);
@@ -86,7 +82,6 @@ class PgsqlColumnTest extends UnitTestCase
'NumericScale' => null,
'IsPrimaryKey' => false,
'IsForeignKey' => true,
- 'IsUnique' => false,
'SequenceName' => null,
);
@@ -101,7 +96,6 @@ class PgsqlColumnTest extends UnitTestCase
'NumericScale' => null,
'IsPrimaryKey' => false,
'IsForeignKey' => false,
- 'IsUnique' => false,
'SequenceName' => null,
);
@@ -116,7 +110,6 @@ class PgsqlColumnTest extends UnitTestCase
'NumericScale' => 4,
'IsPrimaryKey' => false,
'IsForeignKey' => false,
- 'IsUnique' => false,
'SequenceName' => null,
);
$this->assertColumn($columns, $table);
@@ -124,7 +117,6 @@ class PgsqlColumnTest extends UnitTestCase
$this->assertEqual('public', $table->getSchemaName());
$this->assertEqual('address', $table->getTableName());
$this->assertEqual(array('id'), $table->getPrimaryKeys());
- $this->assertEqual(array('username', 'phone'), $table->getUniqueKeys());
}
function assertColumn($columns, $table)
diff --git a/tests/simple_unit/DbCommon/SqliteColumnTest.php b/tests/simple_unit/DbCommon/SqliteColumnTest.php
new file mode 100644
index 00000000..6567106c
--- /dev/null
+++ b/tests/simple_unit/DbCommon/SqliteColumnTest.php
@@ -0,0 +1,30 @@
+<?php
+
+Prado::using('System.Data.*');
+Prado::using('System.Data.Common.Sqlite.TSqliteMetaData');
+Prado::using('System.Data.DataGateway.TTableGateway');
+class SqliteColumnTest extends UnitTestCase
+{
+ /**
+ * @return TSqliteMetaData
+ */
+ function meta_data()
+ {
+ $conn = new TDbConnection('sqlite:c:/test.db');
+ return new TSqliteMetaData($conn);
+ }
+
+ function test_it()
+ {
+ $table = $this->meta_data()->getTableInfo('foo');
+ //var_dump($table);
+ }
+
+ function test_table()
+ {
+ $conn = new TDbConnection('sqlite:c:/test.db');
+ $table = new TTableGateway('Accounts', $conn);
+// var_dump($table->findAll()->readAll());
+ }
+}
+?> \ No newline at end of file