Commit 5d74b25a authored by Steve Müller's avatar Steve Müller

add tests for MySQL decimal/float unsigned declaration

parent 9830694c
......@@ -279,4 +279,46 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
"No differences should be detected with the offline vs online schema."
);
}
/**
* @group DBAL-1082
*/
public function testListDecimalTypeColumns()
{
$tableName = 'test_list_decimal_columns';
$table = new Table($tableName);
$table->addColumn('col', 'decimal');
$table->addColumn('col_unsigned', 'decimal', array('unsigned' => true));
$this->_sm->dropAndCreateTable($table);
$columns = $this->_sm->listTableColumns($tableName);
$this->assertArrayHasKey('col', $columns);
$this->assertArrayHasKey('col_unsigned', $columns);
$this->assertFalse($columns['col']->getUnsigned());
$this->assertTrue($columns['col_unsigned']->getUnsigned());
}
/**
* @group DBAL-1082
*/
public function testListFloatTypeColumns()
{
$tableName = 'test_list_float_columns';
$table = new Table($tableName);
$table->addColumn('col', 'float');
$table->addColumn('col_unsigned', 'float', array('unsigned' => true));
$this->_sm->dropAndCreateTable($table);
$columns = $this->_sm->listTableColumns($tableName);
$this->assertArrayHasKey('col', $columns);
$this->assertArrayHasKey('col_unsigned', $columns);
$this->assertFalse($columns['col']->getUnsigned());
$this->assertTrue($columns['col_unsigned']->getUnsigned());
}
}
......@@ -680,4 +680,34 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
'ALTER TABLE mytable ADD CONSTRAINT fk_foo FOREIGN KEY (foo) REFERENCES foreign_table (id)',
);
}
/**
* {@inheritdoc}
*/
public function getGeneratesDecimalTypeDeclarationSQL()
{
return array(
array(array(), 'NUMERIC(10, 0)'),
array(array('unsigned' => true), 'NUMERIC(10, 0) UNSIGNED'),
array(array('unsigned' => false), 'NUMERIC(10, 0)'),
array(array('precision' => 5), 'NUMERIC(5, 0)'),
array(array('scale' => 5), 'NUMERIC(10, 5)'),
array(array('precision' => 8, 'scale' => 2), 'NUMERIC(8, 2)'),
);
}
/**
* {@inheritdoc}
*/
public function getGeneratesFloatDeclarationSQL()
{
return array(
array(array(), 'DOUBLE PRECISION'),
array(array('unsigned' => true), 'DOUBLE PRECISION UNSIGNED'),
array(array('unsigned' => false), 'DOUBLE PRECISION'),
array(array('precision' => 5), 'DOUBLE PRECISION'),
array(array('scale' => 5), 'DOUBLE PRECISION'),
array(array('precision' => 8, 'scale' => 2), 'DOUBLE PRECISION'),
);
}
}
......@@ -1192,4 +1192,54 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
* @return array
*/
abstract protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL();
/**
* @group DBAL-1082
*
* @dataProvider getGeneratesDecimalTypeDeclarationSQL
*/
public function testGeneratesDecimalTypeDeclarationSQL(array $column, $expectedSql)
{
$this->assertSame($expectedSql, $this->_platform->getDecimalTypeDeclarationSQL($column));
}
/**
* @return array
*/
public function getGeneratesDecimalTypeDeclarationSQL()
{
return array(
array(array(), 'NUMERIC(10, 0)'),
array(array('unsigned' => true), 'NUMERIC(10, 0)'),
array(array('unsigned' => false), 'NUMERIC(10, 0)'),
array(array('precision' => 5), 'NUMERIC(5, 0)'),
array(array('scale' => 5), 'NUMERIC(10, 5)'),
array(array('precision' => 8, 'scale' => 2), 'NUMERIC(8, 2)'),
);
}
/**
* @group DBAL-1082
*
* @dataProvider getGeneratesFloatDeclarationSQL
*/
public function testGeneratesFloatDeclarationSQL(array $column, $expectedSql)
{
$this->assertSame($expectedSql, $this->_platform->getFloatDeclarationSQL($column));
}
/**
* @return array
*/
public function getGeneratesFloatDeclarationSQL()
{
return array(
array(array(), 'DOUBLE PRECISION'),
array(array('unsigned' => true), 'DOUBLE PRECISION'),
array(array('unsigned' => false), 'DOUBLE PRECISION'),
array(array('precision' => 5), 'DOUBLE PRECISION'),
array(array('scale' => 5), 'DOUBLE PRECISION'),
array(array('precision' => 8, 'scale' => 2), 'DOUBLE PRECISION'),
);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment