From a3388622287e218beddfa14a47ed677d4307b36b Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Fri, 25 Mar 2016 17:55:51 +0100 Subject: Removed simpletest and moved all tests in the unit tree Tests are executed now, but a lot of them need fixing. --- tests/unit/Data/DbCommon/PgsqlColumnTest.php | 141 +++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 tests/unit/Data/DbCommon/PgsqlColumnTest.php (limited to 'tests/unit/Data/DbCommon/PgsqlColumnTest.php') diff --git a/tests/unit/Data/DbCommon/PgsqlColumnTest.php b/tests/unit/Data/DbCommon/PgsqlColumnTest.php new file mode 100644 index 00000000..7d7f1177 --- /dev/null +++ b/tests/unit/Data/DbCommon/PgsqlColumnTest.php @@ -0,0 +1,141 @@ +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}"); + } + } + } +} -- cgit v1.2.3