summaryrefslogtreecommitdiff
path: root/tests/simple_unit/DbCommon/PgsqlColumnTest.php
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/PgsqlColumnTest.php
parent3e4e6e66aeb3f8fea4e1eb4237498ef9d2358f63 (diff)
standardize the use of unix eol; use svn properties to enforce native eol
Diffstat (limited to 'tests/simple_unit/DbCommon/PgsqlColumnTest.php')
-rw-r--r--tests/simple_unit/DbCommon/PgsqlColumnTest.php272
1 files changed, 136 insertions, 136 deletions
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