summaryrefslogtreecommitdiff
path: root/tests/simple_unit/DbCommon
diff options
context:
space:
mode:
authorctrlaltca <>2012-07-12 11:21:01 +0000
committerctrlaltca <>2012-07-12 11:21:01 +0000
commit903ae8a581fac1e6917fc3e31d2ad8fb91df80c3 (patch)
treee08bf04f0823650a231227ac3499121270172a23 /tests/simple_unit/DbCommon
parent3e4e6e66aeb3f8fea4e1eb4237498ef9d2358f63 (diff)
standardize the use of unix eol; use svn properties to enforce native eol
Diffstat (limited to 'tests/simple_unit/DbCommon')
-rw-r--r--tests/simple_unit/DbCommon/CommandBuilderMssqlTest.php86
-rw-r--r--tests/simple_unit/DbCommon/CommandBuilderMysqlTest.php32
-rw-r--r--tests/simple_unit/DbCommon/CommandBuilderPgsqlTest.php148
-rw-r--r--tests/simple_unit/DbCommon/MssqlColumnTest.php90
-rw-r--r--tests/simple_unit/DbCommon/Mysql4ColumnTest.php504
-rw-r--r--tests/simple_unit/DbCommon/MysqlColumnTest.php504
-rw-r--r--tests/simple_unit/DbCommon/PgsqlColumnTest.php272
-rw-r--r--tests/simple_unit/DbCommon/SqliteColumnTest.php54
8 files changed, 845 insertions, 845 deletions
diff --git a/tests/simple_unit/DbCommon/CommandBuilderMssqlTest.php b/tests/simple_unit/DbCommon/CommandBuilderMssqlTest.php
index cc7b8b45..f8a4257c 100644
--- a/tests/simple_unit/DbCommon/CommandBuilderMssqlTest.php
+++ b/tests/simple_unit/DbCommon/CommandBuilderMssqlTest.php
@@ -1,46 +1,46 @@
<?php
-
-Prado::using('System.Data.*');
-Prado::using('System.Data.Common.Mssql.TMssqlCommandBuilder');
-
-class CommandBuilderMssqlTest extends UnitTestCase
-{
- protected static $sql = array(
- 'simple' => 'SELECT username, age FROM accounts',
- 'multiple' => 'select a.username, b.name from accounts a, table1 b where a.age = b.id1',
- 'ordering' => 'select a.username, b.name, a.age from accounts a, table1 b where a.age = b.id1 order by age DESC, name',
- 'index' => 'select a.username, b.name, a.age from accounts a, table1 b where a.age = b.id1 ORDER BY 1 DESC, 2 ASC',
- //'compute' => 'SELECT username, age FROM accounts order by age compute avg(age)',
- );
-
- function test_limit()
- {
- $builder = new TMssqlCommandBuilder();
-
- $sql = $builder->applyLimitOffset(self::$sql['simple'], 3);
- $expect = 'SELECT TOP 3 username, age FROM accounts';
- $this->assertEqual($expect, $sql);
-
-
- $sql = $builder->applyLimitOffset(self::$sql['simple'], 3, 2);
- $expect = 'SELECT * FROM (SELECT TOP 3 * FROM (SELECT TOP 5 username, age FROM accounts) as [__inner top table__] ) as [__outer top table__] ';
- $this->assertEqual($expect, $sql);
-
- $sql = $builder->applyLimitOffset(self::$sql['multiple'], 3, 2);
- $expect = 'SELECT * FROM (SELECT TOP 3 * FROM (SELECT TOP 5 a.username, b.name from accounts a, table1 b where a.age = b.id1) as [__inner top table__] ) as [__outer top table__] ';
- $this->assertEqual($sql, $expect);
-
- $sql = $builder->applyLimitOffset(self::$sql['ordering'], 3, 2);
- $expect = 'SELECT * FROM (SELECT TOP 3 * FROM (SELECT TOP 5 a.username, b.name, a.age from accounts a, table1 b where a.age = b.id1 order by age DESC, name) as [__inner top table__] ORDER BY age ASC, name DESC) as [__outer top table__] ORDER BY age DESC, name ASC';
- $this->assertEqual($sql, $expect);
-
- $sql = $builder->applyLimitOffset(self::$sql['index'], 3, 2);
- $expect = 'SELECT * FROM (SELECT TOP 3 * FROM (SELECT TOP 5 a.username, b.name, a.age from accounts a, table1 b where a.age = b.id1 ORDER BY 1 DESC, 2 ASC) as [__inner top table__] ORDER BY 1 ASC, 2 DESC) as [__outer top table__] ORDER BY 1 DESC, 2 ASC';
- $this->assertEqual($expect, $sql);
-
- // $sql = $builder->applyLimitOffset(self::$sql['compute'], 3, 2);
- // var_dump($sql);
- }
-}
+
+Prado::using('System.Data.*');
+Prado::using('System.Data.Common.Mssql.TMssqlCommandBuilder');
+
+class CommandBuilderMssqlTest extends UnitTestCase
+{
+ protected static $sql = array(
+ 'simple' => 'SELECT username, age FROM accounts',
+ 'multiple' => 'select a.username, b.name from accounts a, table1 b where a.age = b.id1',
+ 'ordering' => 'select a.username, b.name, a.age from accounts a, table1 b where a.age = b.id1 order by age DESC, name',
+ 'index' => 'select a.username, b.name, a.age from accounts a, table1 b where a.age = b.id1 ORDER BY 1 DESC, 2 ASC',
+ //'compute' => 'SELECT username, age FROM accounts order by age compute avg(age)',
+ );
+
+ function test_limit()
+ {
+ $builder = new TMssqlCommandBuilder();
+
+ $sql = $builder->applyLimitOffset(self::$sql['simple'], 3);
+ $expect = 'SELECT TOP 3 username, age FROM accounts';
+ $this->assertEqual($expect, $sql);
+
+
+ $sql = $builder->applyLimitOffset(self::$sql['simple'], 3, 2);
+ $expect = 'SELECT * FROM (SELECT TOP 3 * FROM (SELECT TOP 5 username, age FROM accounts) as [__inner top table__] ) as [__outer top table__] ';
+ $this->assertEqual($expect, $sql);
+
+ $sql = $builder->applyLimitOffset(self::$sql['multiple'], 3, 2);
+ $expect = 'SELECT * FROM (SELECT TOP 3 * FROM (SELECT TOP 5 a.username, b.name from accounts a, table1 b where a.age = b.id1) as [__inner top table__] ) as [__outer top table__] ';
+ $this->assertEqual($sql, $expect);
+
+ $sql = $builder->applyLimitOffset(self::$sql['ordering'], 3, 2);
+ $expect = 'SELECT * FROM (SELECT TOP 3 * FROM (SELECT TOP 5 a.username, b.name, a.age from accounts a, table1 b where a.age = b.id1 order by age DESC, name) as [__inner top table__] ORDER BY age ASC, name DESC) as [__outer top table__] ORDER BY age DESC, name ASC';
+ $this->assertEqual($sql, $expect);
+
+ $sql = $builder->applyLimitOffset(self::$sql['index'], 3, 2);
+ $expect = 'SELECT * FROM (SELECT TOP 3 * FROM (SELECT TOP 5 a.username, b.name, a.age from accounts a, table1 b where a.age = b.id1 ORDER BY 1 DESC, 2 ASC) as [__inner top table__] ORDER BY 1 ASC, 2 DESC) as [__outer top table__] ORDER BY 1 DESC, 2 ASC';
+ $this->assertEqual($expect, $sql);
+
+ // $sql = $builder->applyLimitOffset(self::$sql['compute'], 3, 2);
+ // var_dump($sql);
+ }
+}
?> \ No newline at end of file
diff --git a/tests/simple_unit/DbCommon/CommandBuilderMysqlTest.php b/tests/simple_unit/DbCommon/CommandBuilderMysqlTest.php
index 6b744a4b..e248defd 100644
--- a/tests/simple_unit/DbCommon/CommandBuilderMysqlTest.php
+++ b/tests/simple_unit/DbCommon/CommandBuilderMysqlTest.php
@@ -1,19 +1,19 @@
<?php
-Prado::using('System.Data.*');
-Prado::using('System.Data.Common.Mysql.TMysqlMetaData');
-
-class CommandBuilderMysqlTest extends UnitTestCase
-{
- function mysql_meta_data()
- {
- $conn = new TDbConnection('mysql:host=localhost;dbname=tests;port=3307', 'test5','test5');
- return new TMysqlMetaData($conn);
- }
-
- function test()
- {
- $this->mysql_meta_data()->getTableInfo("tests.table1");
- }
-}
+Prado::using('System.Data.*');
+Prado::using('System.Data.Common.Mysql.TMysqlMetaData');
+
+class CommandBuilderMysqlTest extends UnitTestCase
+{
+ function mysql_meta_data()
+ {
+ $conn = new TDbConnection('mysql:host=localhost;dbname=tests;port=3307', 'test5','test5');
+ return new TMysqlMetaData($conn);
+ }
+
+ function test()
+ {
+ $this->mysql_meta_data()->getTableInfo("tests.table1");
+ }
+}
?> \ No newline at end of file
diff --git a/tests/simple_unit/DbCommon/CommandBuilderPgsqlTest.php b/tests/simple_unit/DbCommon/CommandBuilderPgsqlTest.php
index 9ee9c411..63660aee 100644
--- a/tests/simple_unit/DbCommon/CommandBuilderPgsqlTest.php
+++ b/tests/simple_unit/DbCommon/CommandBuilderPgsqlTest.php
@@ -1,76 +1,76 @@
-<?php
-Prado::using('System.Data.*');
-Prado::using('System.Data.Common.Pgsql.TPgsqlMetaData');
-
-class CommandBuilderPgsqlTest extends UnitTestCase
-{
- function pgsql_meta_data()
- {
- $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
- return new TPgsqlMetaData($conn);
- }
-
- function test_insert_command_using_named_array()
- {
- $builder = $this->pgsql_meta_data()->createCommandBuilder('address');
- $address=array(
- 'username' => 'Username',
- 'phone' => 121987,
- 'field1_boolean' => true,
- 'field2_date' => '1213',
- 'field3_double' => 121.1,
- 'field4_integer' => 345,
- 'field6_time' => time(),
- 'field7_timestamp' => time(),
- 'field8_money' => '121.12',
- 'field9_numeric' => 984.22,
- 'int_fk1'=>1,
- 'int_fk2'=>1,
- );
- $insert = $builder->createInsertCommand($address);
- $sql = 'INSERT INTO public.address("username", "phone", "field1_boolean", "field2_date", "field3_double", "field4_integer", "field6_time", "field7_timestamp", "field8_money", "field9_numeric", "int_fk1", "int_fk2") VALUES (:username, :phone, :field1_boolean, :field2_date, :field3_double, :field4_integer, :field6_time, :field7_timestamp, :field8_money, :field9_numeric, :int_fk1, :int_fk2)';
- $this->assertEqual($sql, $insert->Text);
- }
-
- function test_update_command()
- {
- $builder = $this->pgsql_meta_data()->createCommandBuilder('address');
- $data = array(
- 'phone' => 9809,
- 'int_fk1' => 1212,
- );
- $update = $builder->createUpdateCommand($data, '1');
- $sql = 'UPDATE public.address SET "phone" = :phone, "int_fk1" = :int_fk1 WHERE 1';
- $this->assertEqual($sql, $update->Text);
- }
-
- function test_delete_command()
- {
- $builder = $this->pgsql_meta_data()->createCommandBuilder('address');
- $where = 'phone is NULL';
- $delete = $builder->createDeleteCommand($where);
- $sql = 'DELETE FROM public.address WHERE phone is NULL';
- $this->assertEqual($sql, $delete->Text);
- }
-
- function test_select_limit()
- {
- $meta = $this->pgsql_meta_data();
- $builder = $meta->createCommandBuilder('address');
- $query = 'SELECT * FROM '.$meta->getTableInfo('address')->getTableFullName();
-
- $limit = $builder->applyLimitOffset($query, 1);
- $expect = $query.' LIMIT 1';
- $this->assertEqual($expect, $limit);
-
- $limit = $builder->applyLimitOffset($query, -1, 10);
- $expect = $query.' OFFSET 10';
- $this->assertEqual($expect, $limit);
-
- $limit = $builder->applyLimitOffset($query, 2, 3);
- $expect = $query.' LIMIT 2 OFFSET 3';
- $this->assertEqual($expect, $limit);
- }
-}
+<?php
+Prado::using('System.Data.*');
+Prado::using('System.Data.Common.Pgsql.TPgsqlMetaData');
+
+class CommandBuilderPgsqlTest extends UnitTestCase
+{
+ function pgsql_meta_data()
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ return new TPgsqlMetaData($conn);
+ }
+
+ function test_insert_command_using_named_array()
+ {
+ $builder = $this->pgsql_meta_data()->createCommandBuilder('address');
+ $address=array(
+ 'username' => 'Username',
+ 'phone' => 121987,
+ 'field1_boolean' => true,
+ 'field2_date' => '1213',
+ 'field3_double' => 121.1,
+ 'field4_integer' => 345,
+ 'field6_time' => time(),
+ 'field7_timestamp' => time(),
+ 'field8_money' => '121.12',
+ 'field9_numeric' => 984.22,
+ 'int_fk1'=>1,
+ 'int_fk2'=>1,
+ );
+ $insert = $builder->createInsertCommand($address);
+ $sql = 'INSERT INTO public.address("username", "phone", "field1_boolean", "field2_date", "field3_double", "field4_integer", "field6_time", "field7_timestamp", "field8_money", "field9_numeric", "int_fk1", "int_fk2") VALUES (:username, :phone, :field1_boolean, :field2_date, :field3_double, :field4_integer, :field6_time, :field7_timestamp, :field8_money, :field9_numeric, :int_fk1, :int_fk2)';
+ $this->assertEqual($sql, $insert->Text);
+ }
+
+ function test_update_command()
+ {
+ $builder = $this->pgsql_meta_data()->createCommandBuilder('address');
+ $data = array(
+ 'phone' => 9809,
+ 'int_fk1' => 1212,
+ );
+ $update = $builder->createUpdateCommand($data, '1');
+ $sql = 'UPDATE public.address SET "phone" = :phone, "int_fk1" = :int_fk1 WHERE 1';
+ $this->assertEqual($sql, $update->Text);
+ }
+
+ function test_delete_command()
+ {
+ $builder = $this->pgsql_meta_data()->createCommandBuilder('address');
+ $where = 'phone is NULL';
+ $delete = $builder->createDeleteCommand($where);
+ $sql = 'DELETE FROM public.address WHERE phone is NULL';
+ $this->assertEqual($sql, $delete->Text);
+ }
+
+ function test_select_limit()
+ {
+ $meta = $this->pgsql_meta_data();
+ $builder = $meta->createCommandBuilder('address');
+ $query = 'SELECT * FROM '.$meta->getTableInfo('address')->getTableFullName();
+
+ $limit = $builder->applyLimitOffset($query, 1);
+ $expect = $query.' LIMIT 1';
+ $this->assertEqual($expect, $limit);
+
+ $limit = $builder->applyLimitOffset($query, -1, 10);
+ $expect = $query.' OFFSET 10';
+ $this->assertEqual($expect, $limit);
+
+ $limit = $builder->applyLimitOffset($query, 2, 3);
+ $expect = $query.' LIMIT 2 OFFSET 3';
+ $this->assertEqual($expect, $limit);
+ }
+}
?> \ No newline at end of file
diff --git a/tests/simple_unit/DbCommon/MssqlColumnTest.php b/tests/simple_unit/DbCommon/MssqlColumnTest.php
index db2df03b..16d73bc4 100644
--- a/tests/simple_unit/DbCommon/MssqlColumnTest.php
+++ b/tests/simple_unit/DbCommon/MssqlColumnTest.php
@@ -1,48 +1,48 @@
<?php
-
-Prado::using('System.Data.*');
-Prado::using('System.Data.Common.Mssql.TMssqlMetaData');
-Prado::using('System.Data.DataGateway.TTableGateway');
-
-class MssqlColumnTest extends UnitTestCase
-{
- function get_conn()
- {
- return new TDbConnection('mssql:host=localhost\\sqlexpress', 'test', 'test01');
- }
-
- /**
- * @return TMssqlMetaData
- */
- function meta_data()
- {
- return new TMssqlMetaData($this->get_conn());
- }
-
- function test_insert()
- {
- $table = new TTableGateway('table1', $this->get_conn());
- $this->assertTrue(is_int($table->insert(array('name'=>'cool'))));
- }
-
-/* function test_meta()
- {
- $result = $this->meta_data()->getTableInfo("bar");
- var_dump($result);
- }
-*/
- /*function test_insert()
- {
- $table = new TTableGateway('table1', $this->get_conn());
- //var_dump($table->insert(array('name'=>'cool')));
- //var_dump($table->getLastInsertId());
- $criteria = new TSqlCriteria();
- $criteria->Limit = 5;
- $criteria->Offset = 2;
-
- $result = $table->findAll($criteria)->readAll();
- var_dump($result);
- }*/
-}
+
+Prado::using('System.Data.*');
+Prado::using('System.Data.Common.Mssql.TMssqlMetaData');
+Prado::using('System.Data.DataGateway.TTableGateway');
+
+class MssqlColumnTest extends UnitTestCase
+{
+ function get_conn()
+ {
+ return new TDbConnection('mssql:host=localhost\\sqlexpress', 'test', 'test01');
+ }
+
+ /**
+ * @return TMssqlMetaData
+ */
+ function meta_data()
+ {
+ return new TMssqlMetaData($this->get_conn());
+ }
+
+ function test_insert()
+ {
+ $table = new TTableGateway('table1', $this->get_conn());
+ $this->assertTrue(is_int($table->insert(array('name'=>'cool'))));
+ }
+
+/* function test_meta()
+ {
+ $result = $this->meta_data()->getTableInfo("bar");
+ var_dump($result);
+ }
+*/
+ /*function test_insert()
+ {
+ $table = new TTableGateway('table1', $this->get_conn());
+ //var_dump($table->insert(array('name'=>'cool')));
+ //var_dump($table->getLastInsertId());
+ $criteria = new TSqlCriteria();
+ $criteria->Limit = 5;
+ $criteria->Offset = 2;
+
+ $result = $table->findAll($criteria)->readAll();
+ var_dump($result);
+ }*/
+}
?> \ No newline at end of file
diff --git a/tests/simple_unit/DbCommon/Mysql4ColumnTest.php b/tests/simple_unit/DbCommon/Mysql4ColumnTest.php
index d69f3093..234a212f 100644
--- a/tests/simple_unit/DbCommon/Mysql4ColumnTest.php
+++ b/tests/simple_unit/DbCommon/Mysql4ColumnTest.php
@@ -1,254 +1,254 @@
-<?php
-Prado::using('System.Data.*');
-Prado::using('System.Data.Common.Mysql.TMysqlMetaData');
-
-class Mysql4ColumnTest extends UnitTestCase
-{
- function create_meta_data()
- {
- $conn = new TDbConnection('mysql:host=localhost;dbname=tests;port=3306', 'test4','test4');
- return new TMysqlMetaData($conn);
- }
-
- function test_columns()
- {
- $table = $this->create_meta_data()->getTableInfo('table1');
- $this->assertEqual(count($table->getColumns()), 18);
-
- $columns['id'] = array(
- 'ColumnName' => '`id`',
- 'ColumnSize' => 10,
- 'ColumnIndex' => 0,
- 'DbType' => 'int unsigned',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => true,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => true,
- );
-
- $columns['name'] = array(
- 'ColumnName' => '`name`',
- 'ColumnSize' => 45,
- 'ColumnIndex' => 1,
- 'DbType' => 'varchar',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => true,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field1'] = array(
- 'ColumnName' => '`field1`',
- 'ColumnSize' => 4,
- 'ColumnIndex' => 2,
- 'DbType' => 'tinyint',
- 'AllowNull' => false,
- 'DefaultValue' => '0',
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field2_text'] = array(
- 'ColumnName' => '`field2_text`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 3,
- 'DbType' => 'text',
- 'AllowNull' => true,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field3_date'] = array(
- 'ColumnName' => '`field3_date`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 4,
- 'DbType' => 'date',
- 'AllowNull' => true,
- 'DefaultValue' => '2007-02-25',
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field4_float'] = array(
- 'ColumnName' => '`field4_float`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 5,
- 'DbType' => 'float',
- 'AllowNull' => false,
- 'DefaultValue' => 10,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field5_float'] = array(
- 'ColumnName' => '`field5_float`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 6,
- 'DbType' => 'float',
- 'AllowNull' => false,
- 'DefaultValue' => '0.0000',
- 'NumericPrecision' => 5,
- 'NumericScale' => 4,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field6_double'] = array(
- 'ColumnName' => '`field6_double`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 7,
- 'DbType' => 'double',
- 'AllowNull' => false,
- 'DefaultValue' => '0',
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field7_datetime'] = array(
- 'ColumnName' => '`field7_datetime`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 8,
- 'DbType' => 'datetime',
- 'AllowNull' => false,
- 'DefaultValue' => '0000-00-00 00:00:00',
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field8_timestamp'] = array(
- 'ColumnName' => '`field8_timestamp`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 9,
- 'DbType' => 'timestamp',
- 'AllowNull' => true,
- 'DefaultValue' => 'CURRENT_TIMESTAMP',
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field9_time'] = array(
- 'ColumnName' => '`field9_time`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 10,
- 'DbType' => 'time',
- 'AllowNull' => false,
- 'DefaultValue' => '00:00:00',
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field10_year'] = array(
- 'ColumnName' => '`field10_year`',
- 'ColumnSize' => 4,
- 'ColumnIndex' => 11,
- 'DbType' => 'year',
- 'AllowNull' => false,
- 'DefaultValue' => '0000',
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field11_enum'] = array(
- 'ColumnName' => '`field11_enum`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 12,
- 'DbType' => 'enum',
- 'AllowNull' => false,
- 'DefaultValue' => 'one',
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- 'DbTypeValues' => array('one', 'two', 'three'),
- );
-
- $columns['field12_SET'] = array(
- 'ColumnName' => '`field12_SET`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 13,
- 'DbType' => 'set',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- 'DbTypeValues' => array('blue', 'red', 'green'),
- );
-
- $this->assertColumn($columns, $table);
-
- $this->assertNull($table->getSchemaName());
- $this->assertEqual('table1', $table->getTableName());
- $this->assertEqual(array('id', 'name'), $table->getPrimaryKeys());
- }
-
- function assertColumn($columns, $table)
- {
- foreach($columns as $id=>$asserts)
- {
- $column = $table->Columns[$id];
- foreach($asserts as $property=>$assert)
- {
- $ofAssert= var_export($assert,true);
- $value = $column->{$property};
- $ofValue = var_export($value, true);
- $this->assertEqual($value, $assert,
- "Column [{$id}] {$property} value {$ofValue} did not match {$ofAssert}");
- }
- }
- }
-}
+<?php
+Prado::using('System.Data.*');
+Prado::using('System.Data.Common.Mysql.TMysqlMetaData');
+
+class Mysql4ColumnTest extends UnitTestCase
+{
+ function create_meta_data()
+ {
+ $conn = new TDbConnection('mysql:host=localhost;dbname=tests;port=3306', 'test4','test4');
+ return new TMysqlMetaData($conn);
+ }
+
+ function test_columns()
+ {
+ $table = $this->create_meta_data()->getTableInfo('table1');
+ $this->assertEqual(count($table->getColumns()), 18);
+
+ $columns['id'] = array(
+ 'ColumnName' => '`id`',
+ 'ColumnSize' => 10,
+ 'ColumnIndex' => 0,
+ 'DbType' => 'int unsigned',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => true,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => true,
+ );
+
+ $columns['name'] = array(
+ 'ColumnName' => '`name`',
+ 'ColumnSize' => 45,
+ 'ColumnIndex' => 1,
+ 'DbType' => 'varchar',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => true,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field1'] = array(
+ 'ColumnName' => '`field1`',
+ 'ColumnSize' => 4,
+ 'ColumnIndex' => 2,
+ 'DbType' => 'tinyint',
+ 'AllowNull' => false,
+ 'DefaultValue' => '0',
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field2_text'] = array(
+ 'ColumnName' => '`field2_text`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 3,
+ 'DbType' => 'text',
+ 'AllowNull' => true,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field3_date'] = array(
+ 'ColumnName' => '`field3_date`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 4,
+ 'DbType' => 'date',
+ 'AllowNull' => true,
+ 'DefaultValue' => '2007-02-25',
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field4_float'] = array(
+ 'ColumnName' => '`field4_float`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 5,
+ 'DbType' => 'float',
+ 'AllowNull' => false,
+ 'DefaultValue' => 10,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field5_float'] = array(
+ 'ColumnName' => '`field5_float`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 6,
+ 'DbType' => 'float',
+ 'AllowNull' => false,
+ 'DefaultValue' => '0.0000',
+ 'NumericPrecision' => 5,
+ 'NumericScale' => 4,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field6_double'] = array(
+ 'ColumnName' => '`field6_double`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 7,
+ 'DbType' => 'double',
+ 'AllowNull' => false,
+ 'DefaultValue' => '0',
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field7_datetime'] = array(
+ 'ColumnName' => '`field7_datetime`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 8,
+ 'DbType' => 'datetime',
+ 'AllowNull' => false,
+ 'DefaultValue' => '0000-00-00 00:00:00',
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field8_timestamp'] = array(
+ 'ColumnName' => '`field8_timestamp`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 9,
+ 'DbType' => 'timestamp',
+ 'AllowNull' => true,
+ 'DefaultValue' => 'CURRENT_TIMESTAMP',
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field9_time'] = array(
+ 'ColumnName' => '`field9_time`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 10,
+ 'DbType' => 'time',
+ 'AllowNull' => false,
+ 'DefaultValue' => '00:00:00',
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field10_year'] = array(
+ 'ColumnName' => '`field10_year`',
+ 'ColumnSize' => 4,
+ 'ColumnIndex' => 11,
+ 'DbType' => 'year',
+ 'AllowNull' => false,
+ 'DefaultValue' => '0000',
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field11_enum'] = array(
+ 'ColumnName' => '`field11_enum`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 12,
+ 'DbType' => 'enum',
+ 'AllowNull' => false,
+ 'DefaultValue' => 'one',
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ 'DbTypeValues' => array('one', 'two', 'three'),
+ );
+
+ $columns['field12_SET'] = array(
+ 'ColumnName' => '`field12_SET`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 13,
+ 'DbType' => 'set',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ 'DbTypeValues' => array('blue', 'red', 'green'),
+ );
+
+ $this->assertColumn($columns, $table);
+
+ $this->assertNull($table->getSchemaName());
+ $this->assertEqual('table1', $table->getTableName());
+ $this->assertEqual(array('id', 'name'), $table->getPrimaryKeys());
+ }
+
+ function assertColumn($columns, $table)
+ {
+ foreach($columns as $id=>$asserts)
+ {
+ $column = $table->Columns[$id];
+ foreach($asserts as $property=>$assert)
+ {
+ $ofAssert= var_export($assert,true);
+ $value = $column->{$property};
+ $ofValue = var_export($value, true);
+ $this->assertEqual($value, $assert,
+ "Column [{$id}] {$property} value {$ofValue} did not match {$ofAssert}");
+ }
+ }
+ }
+}
?> \ No newline at end of file
diff --git a/tests/simple_unit/DbCommon/MysqlColumnTest.php b/tests/simple_unit/DbCommon/MysqlColumnTest.php
index 1508f2c6..08fdb545 100644
--- a/tests/simple_unit/DbCommon/MysqlColumnTest.php
+++ b/tests/simple_unit/DbCommon/MysqlColumnTest.php
@@ -1,254 +1,254 @@
-<?php
-Prado::using('System.Data.*');
-Prado::using('System.Data.Common.Mysql.TMysqlMetaData');
-
-class MysqlColumnTest extends UnitTestCase
-{
- function create_meta_data()
- {
- $conn = new TDbConnection('mysql:host=localhost;dbname=tests;port=3307', 'test5','test5');
- return new TMysqlMetaData($conn);
- }
-
- function test_columns()
- {
- $table = $this->create_meta_data()->getTableInfo('table1');
- $this->assertEqual(count($table->getColumns()), 18);
-
- $columns['id'] = array(
- 'ColumnName' => '`id`',
- 'ColumnSize' => 10,
- 'ColumnIndex' => 0,
- 'DbType' => 'int unsigned',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => true,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => true,
- );
-
- $columns['name'] = array(
- 'ColumnName' => '`name`',
- 'ColumnSize' => 45,
- 'ColumnIndex' => 1,
- 'DbType' => 'varchar',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => true,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field1'] = array(
- 'ColumnName' => '`field1`',
- 'ColumnSize' => 4,
- 'ColumnIndex' => 2,
- 'DbType' => 'tinyint',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field2_text'] = array(
- 'ColumnName' => '`field2_text`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 3,
- 'DbType' => 'text',
- 'AllowNull' => true,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field3_date'] = array(
- 'ColumnName' => '`field3_date`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 4,
- 'DbType' => 'date',
- 'AllowNull' => true,
- 'DefaultValue' => '2007-02-25',
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field4_float'] = array(
- 'ColumnName' => '`field4_float`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 5,
- 'DbType' => 'float',
- 'AllowNull' => false,
- 'DefaultValue' => 10,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field5_float'] = array(
- 'ColumnName' => '`field5_float`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 6,
- 'DbType' => 'float',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => 5,
- 'NumericScale' => 4,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field6_double'] = array(
- 'ColumnName' => '`field6_double`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 7,
- 'DbType' => 'double',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field7_datetime'] = array(
- 'ColumnName' => '`field7_datetime`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 8,
- 'DbType' => 'datetime',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field8_timestamp'] = array(
- 'ColumnName' => '`field8_timestamp`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 9,
- 'DbType' => 'timestamp',
- 'AllowNull' => true,
- 'DefaultValue' => 'CURRENT_TIMESTAMP',
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field9_time'] = array(
- 'ColumnName' => '`field9_time`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 10,
- 'DbType' => 'time',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field10_year'] = array(
- 'ColumnName' => '`field10_year`',
- 'ColumnSize' => 4,
- 'ColumnIndex' => 11,
- 'DbType' => 'year',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- );
-
- $columns['field11_enum'] = array(
- 'ColumnName' => '`field11_enum`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 12,
- 'DbType' => 'enum',
- 'AllowNull' => false,
- 'DefaultValue' => 'one',
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- 'DbTypeValues' => array('one', 'two', 'three'),
- );
-
- $columns['field12_SET'] = array(
- 'ColumnName' => '`field12_SET`',
- 'ColumnSize' => null,
- 'ColumnIndex' => 13,
- 'DbType' => 'set',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- 'AutoIncrement' => false,
- 'DbTypeValues' => array('blue', 'red', 'green'),
- );
-
- $this->assertColumn($columns, $table);
-
- $this->assertNull($table->getSchemaName());
- $this->assertEqual('table1', $table->getTableName());
- $this->assertEqual(array('id', 'name'), $table->getPrimaryKeys());
- }
-
- function assertColumn($columns, $table)
- {
- foreach($columns as $id=>$asserts)
- {
- $column = $table->Columns[$id];
- foreach($asserts as $property=>$assert)
- {
- $ofAssert= var_export($assert,true);
- $value = $column->{$property};
- $ofValue = var_export($value, true);
- $this->assertEqual($value, $assert,
- "Column [{$id}] {$property} value {$ofValue} did not match {$ofAssert}");
- }
- }
- }
-}
+<?php
+Prado::using('System.Data.*');
+Prado::using('System.Data.Common.Mysql.TMysqlMetaData');
+
+class MysqlColumnTest extends UnitTestCase
+{
+ function create_meta_data()
+ {
+ $conn = new TDbConnection('mysql:host=localhost;dbname=tests;port=3307', 'test5','test5');
+ return new TMysqlMetaData($conn);
+ }
+
+ function test_columns()
+ {
+ $table = $this->create_meta_data()->getTableInfo('table1');
+ $this->assertEqual(count($table->getColumns()), 18);
+
+ $columns['id'] = array(
+ 'ColumnName' => '`id`',
+ 'ColumnSize' => 10,
+ 'ColumnIndex' => 0,
+ 'DbType' => 'int unsigned',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => true,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => true,
+ );
+
+ $columns['name'] = array(
+ 'ColumnName' => '`name`',
+ 'ColumnSize' => 45,
+ 'ColumnIndex' => 1,
+ 'DbType' => 'varchar',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => true,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field1'] = array(
+ 'ColumnName' => '`field1`',
+ 'ColumnSize' => 4,
+ 'ColumnIndex' => 2,
+ 'DbType' => 'tinyint',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field2_text'] = array(
+ 'ColumnName' => '`field2_text`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 3,
+ 'DbType' => 'text',
+ 'AllowNull' => true,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field3_date'] = array(
+ 'ColumnName' => '`field3_date`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 4,
+ 'DbType' => 'date',
+ 'AllowNull' => true,
+ 'DefaultValue' => '2007-02-25',
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field4_float'] = array(
+ 'ColumnName' => '`field4_float`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 5,
+ 'DbType' => 'float',
+ 'AllowNull' => false,
+ 'DefaultValue' => 10,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field5_float'] = array(
+ 'ColumnName' => '`field5_float`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 6,
+ 'DbType' => 'float',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => 5,
+ 'NumericScale' => 4,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field6_double'] = array(
+ 'ColumnName' => '`field6_double`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 7,
+ 'DbType' => 'double',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field7_datetime'] = array(
+ 'ColumnName' => '`field7_datetime`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 8,
+ 'DbType' => 'datetime',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field8_timestamp'] = array(
+ 'ColumnName' => '`field8_timestamp`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 9,
+ 'DbType' => 'timestamp',
+ 'AllowNull' => true,
+ 'DefaultValue' => 'CURRENT_TIMESTAMP',
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field9_time'] = array(
+ 'ColumnName' => '`field9_time`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 10,
+ 'DbType' => 'time',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field10_year'] = array(
+ 'ColumnName' => '`field10_year`',
+ 'ColumnSize' => 4,
+ 'ColumnIndex' => 11,
+ 'DbType' => 'year',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ );
+
+ $columns['field11_enum'] = array(
+ 'ColumnName' => '`field11_enum`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 12,
+ 'DbType' => 'enum',
+ 'AllowNull' => false,
+ 'DefaultValue' => 'one',
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ 'DbTypeValues' => array('one', 'two', 'three'),
+ );
+
+ $columns['field12_SET'] = array(
+ 'ColumnName' => '`field12_SET`',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 13,
+ 'DbType' => 'set',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ 'AutoIncrement' => false,
+ 'DbTypeValues' => array('blue', 'red', 'green'),
+ );
+
+ $this->assertColumn($columns, $table);
+
+ $this->assertNull($table->getSchemaName());
+ $this->assertEqual('table1', $table->getTableName());
+ $this->assertEqual(array('id', 'name'), $table->getPrimaryKeys());
+ }
+
+ function assertColumn($columns, $table)
+ {
+ foreach($columns as $id=>$asserts)
+ {
+ $column = $table->Columns[$id];
+ foreach($asserts as $property=>$assert)
+ {
+ $ofAssert= var_export($assert,true);
+ $value = $column->{$property};
+ $ofValue = var_export($value, true);
+ $this->assertEqual($value, $assert,
+ "Column [{$id}] {$property} value {$ofValue} did not match {$ofAssert}");
+ }
+ }
+ }
+}
?> \ No newline at end of file
diff --git a/tests/simple_unit/DbCommon/PgsqlColumnTest.php b/tests/simple_unit/DbCommon/PgsqlColumnTest.php
index de12083e..a16de964 100644
--- a/tests/simple_unit/DbCommon/PgsqlColumnTest.php
+++ b/tests/simple_unit/DbCommon/PgsqlColumnTest.php
@@ -1,139 +1,139 @@
<?php
-
-Prado::using('System.Data.*');
-Prado::using('System.Data.Common.Pgsql.TPgsqlMetaData');
-class PgsqlColumnTest extends UnitTestCase
-{
- function create_meta_data()
- {
- $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
- return new TPgsqlMetaData($conn);
- }
-
- function test_text_column_def()
- {
- $table = $this->create_meta_data()->getTableInfo('public.address');
- $this->assertEqual(count($table->getColumns()), 14);
-
- $columns['id'] = array(
- 'ColumnName' => '"id"',
- 'ColumnSize' => null,
- 'ColumnIndex' => 0,
- 'DbType' => 'integer',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => true,
- 'IsForeignKey' => false,
- 'SequenceName' => 'public.address_id_seq',
- );
-
- $columns['username'] = array(
- 'ColumnName' => '"username"',
- 'ColumnSize' => 128,
- 'ColumnIndex' => 1,
- 'DbType' => 'character varying',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- );
-
- $columns['phone'] = array(
- 'ColumnName' => '"phone"',
- 'ColumnSize' => 40,
- 'ColumnIndex' => 2,
- 'DbType' => 'character',
- 'AllowNull' => false,
- 'DefaultValue' => "'hello'::bpchar",
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- );
-
- $columns['field1_boolean'] = array(
- 'ColumnName' => '"field1_boolean"',
- 'ColumnSize' => null,
- 'ColumnIndex' => 3,
- 'DbType' => 'boolean',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- );
-
- $columns['field4_integer'] = array(
- 'ColumnName' => '"field4_integer"',
- 'ColumnSize' => null,
- 'ColumnIndex' => 6,
- 'DbType' => 'integer',
- 'AllowNull' => false,
- 'DefaultValue' => "1",
- 'NumericPrecision' => null,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => true,
- 'SequenceName' => null,
- );
-
- $columns['field7_timestamp'] = array(
- 'ColumnName' => '"field7_timestamp"',
- 'ColumnSize' => 2,
- 'ColumnIndex' => 9,
- 'DbType' => 'timestamp without time zone',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => 6,
- 'NumericScale' => null,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- );
-
- $columns['field9_numeric'] = array(
- 'ColumnName' => '"field9_numeric"',
- 'ColumnSize' => 393220,
- 'ColumnIndex' => 11,
- 'DbType' => 'numeric',
- 'AllowNull' => false,
- 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
- 'NumericPrecision' => 6,
- 'NumericScale' => 4,
- 'IsPrimaryKey' => false,
- 'IsForeignKey' => false,
- 'SequenceName' => null,
- );
- $this->assertColumn($columns, $table);
-
- $this->assertEqual('public', $table->getSchemaName());
- $this->assertEqual('address', $table->getTableName());
- $this->assertEqual(array('id'), $table->getPrimaryKeys());
- }
-
- function assertColumn($columns, $table)
- {
- foreach($columns as $id=>$asserts)
- {
- $column = $table->Columns[$id];
- foreach($asserts as $property=>$assert)
- {
- $ofAssert= var_export($assert,true);
- $value = $column->{$property};
- $ofValue = var_export($value, true);
- $this->assertEqual($value, $assert,
- "Column [{$id}] {$property} value {$ofValue} did not match {$ofAssert}");
- }
- }
- }
-}
+
+Prado::using('System.Data.*');
+Prado::using('System.Data.Common.Pgsql.TPgsqlMetaData');
+class PgsqlColumnTest extends UnitTestCase
+{
+ function create_meta_data()
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ return new TPgsqlMetaData($conn);
+ }
+
+ function test_text_column_def()
+ {
+ $table = $this->create_meta_data()->getTableInfo('public.address');
+ $this->assertEqual(count($table->getColumns()), 14);
+
+ $columns['id'] = array(
+ 'ColumnName' => '"id"',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 0,
+ 'DbType' => 'integer',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => true,
+ 'IsForeignKey' => false,
+ 'SequenceName' => 'public.address_id_seq',
+ );
+
+ $columns['username'] = array(
+ 'ColumnName' => '"username"',
+ 'ColumnSize' => 128,
+ 'ColumnIndex' => 1,
+ 'DbType' => 'character varying',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ );
+
+ $columns['phone'] = array(
+ 'ColumnName' => '"phone"',
+ 'ColumnSize' => 40,
+ 'ColumnIndex' => 2,
+ 'DbType' => 'character',
+ 'AllowNull' => false,
+ 'DefaultValue' => "'hello'::bpchar",
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ );
+
+ $columns['field1_boolean'] = array(
+ 'ColumnName' => '"field1_boolean"',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 3,
+ 'DbType' => 'boolean',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ );
+
+ $columns['field4_integer'] = array(
+ 'ColumnName' => '"field4_integer"',
+ 'ColumnSize' => null,
+ 'ColumnIndex' => 6,
+ 'DbType' => 'integer',
+ 'AllowNull' => false,
+ 'DefaultValue' => "1",
+ 'NumericPrecision' => null,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => true,
+ 'SequenceName' => null,
+ );
+
+ $columns['field7_timestamp'] = array(
+ 'ColumnName' => '"field7_timestamp"',
+ 'ColumnSize' => 2,
+ 'ColumnIndex' => 9,
+ 'DbType' => 'timestamp without time zone',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => 6,
+ 'NumericScale' => null,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ );
+
+ $columns['field9_numeric'] = array(
+ 'ColumnName' => '"field9_numeric"',
+ 'ColumnSize' => 393220,
+ 'ColumnIndex' => 11,
+ 'DbType' => 'numeric',
+ 'AllowNull' => false,
+ 'DefaultValue' => TDbTableColumn::UNDEFINED_VALUE,
+ 'NumericPrecision' => 6,
+ 'NumericScale' => 4,
+ 'IsPrimaryKey' => false,
+ 'IsForeignKey' => false,
+ 'SequenceName' => null,
+ );
+ $this->assertColumn($columns, $table);
+
+ $this->assertEqual('public', $table->getSchemaName());
+ $this->assertEqual('address', $table->getTableName());
+ $this->assertEqual(array('id'), $table->getPrimaryKeys());
+ }
+
+ function assertColumn($columns, $table)
+ {
+ foreach($columns as $id=>$asserts)
+ {
+ $column = $table->Columns[$id];
+ foreach($asserts as $property=>$assert)
+ {
+ $ofAssert= var_export($assert,true);
+ $value = $column->{$property};
+ $ofValue = var_export($value, true);
+ $this->assertEqual($value, $assert,
+ "Column [{$id}] {$property} value {$ofValue} did not match {$ofAssert}");
+ }
+ }
+ }
+}
?> \ No newline at end of file
diff --git a/tests/simple_unit/DbCommon/SqliteColumnTest.php b/tests/simple_unit/DbCommon/SqliteColumnTest.php
index 36a4baab..246c4a27 100644
--- a/tests/simple_unit/DbCommon/SqliteColumnTest.php
+++ b/tests/simple_unit/DbCommon/SqliteColumnTest.php
@@ -1,29 +1,29 @@
-<?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());
- }
+<?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