Commit 068617eb authored by Claudio Zizza's avatar Claudio Zizza Committed by Steve Müller

unittest adapted for all plattforms using AbstractPlatformTestCase

parent bb4f632a
...@@ -657,4 +657,14 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase ...@@ -657,4 +657,14 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
{ {
return 'INDEX `select` (foo)'; return 'INDEX `select` (foo)';
} }
/**
* {@inheritdoc}
*/
protected function getAlterStringToFixedStringSQL()
{
return array(
'ALTER TABLE mytable CHANGE name name CHAR(2) NOT NULL',
);
}
} }
...@@ -1128,4 +1128,35 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase ...@@ -1128,4 +1128,35 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
* @return array * @return array
*/ */
abstract protected function getQuotesTableIdentifiersInAlterTableSQL(); abstract protected function getQuotesTableIdentifiersInAlterTableSQL();
/**
* @group DBAL-1090
*/
public function testAlterStringToFixedString()
{
$table = new Table('mytable');
$table->addColumn('name', 'string', array('length' => 2));
$tableDiff = new TableDiff('mytable');
$tableDiff->fromTable = $table;
$tableDiff->changedColumns['name'] = new \Doctrine\DBAL\Schema\ColumnDiff(
'name', new \Doctrine\DBAL\Schema\Column(
'name', \Doctrine\DBAL\Types\Type::getType('string'), array('fixed' => true, 'length' => 2)
),
array('fixed')
);
$sql = $this->_platform->getAlterTableSQL($tableDiff);
$expectedSql = $this->getAlterStringToFixedStringSQL();
$this->assertEquals($expectedSql, $sql);
}
/**
* @return array
*/
abstract protected function getAlterStringToFixedStringSQL();
} }
...@@ -757,30 +757,12 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa ...@@ -757,30 +757,12 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
} }
/** /**
* @group DBAL-1090 * {@inheritdoc}
*/ */
public function testAlterStringToFixedString() protected function getAlterStringToFixedStringSQL()
{ {
return array(
$table = new Table('mytable');
$table->addColumn('name', 'string', array('length' => 2));
$tableDiff = new TableDiff('mytable');
$tableDiff->fromTable = $table;
$tableDiff->changedColumns['dloo1'] = new \Doctrine\DBAL\Schema\ColumnDiff(
'name', new \Doctrine\DBAL\Schema\Column(
'name', \Doctrine\DBAL\Types\Type::getType('string'), array('fixed' => true, 'length' => 2)
),
array('fixed')
);
$sql = $this->_platform->getAlterTableSQL($tableDiff);
$expectedSql = array(
'ALTER TABLE mytable ALTER name TYPE CHAR(2)', 'ALTER TABLE mytable ALTER name TYPE CHAR(2)',
); );
$this->assertEquals($expectedSql, $sql);
} }
} }
...@@ -1202,4 +1202,14 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas ...@@ -1202,4 +1202,14 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas
{ {
return 'INDEX [select] (foo)'; return 'INDEX [select] (foo)';
} }
/**
* {@inheritdoc}
*/
protected function getAlterStringToFixedStringSQL()
{
return array(
'ALTER TABLE mytable ALTER COLUMN name NCHAR(2) NOT NULL',
);
}
} }
...@@ -639,4 +639,15 @@ class DB2PlatformTest extends AbstractPlatformTestCase ...@@ -639,4 +639,15 @@ class DB2PlatformTest extends AbstractPlatformTestCase
{ {
return false; return false;
} }
/**
* {@inheritdoc}
*/
protected function getAlterStringToFixedStringSQL()
{
return array(
'ALTER TABLE mytable ALTER COLUMN name SET DATA TYPE CHAR(2)',
'CALL SYSPROC.ADMIN_CMD (\'REORG TABLE mytable\')',
);
}
} }
...@@ -658,4 +658,14 @@ EOD; ...@@ -658,4 +658,14 @@ EOD;
{ {
return 'INDEX "select" (foo)'; return 'INDEX "select" (foo)';
} }
/**
* {@inheritdoc}
*/
protected function getAlterStringToFixedStringSQL()
{
return array(
'ALTER TABLE mytable MODIFY (name CHAR(2) DEFAULT NULL)',
);
}
} }
...@@ -951,4 +951,14 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase ...@@ -951,4 +951,14 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
{ {
return false; return false;
} }
/**
* {@inheritdoc}
*/
protected function getAlterStringToFixedStringSQL()
{
return array(
'ALTER TABLE mytable ALTER name CHAR(2) NOT NULL',
);
}
} }
...@@ -624,4 +624,18 @@ class SqlitePlatformTest extends AbstractPlatformTestCase ...@@ -624,4 +624,18 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
{ {
return 'INDEX "select" (foo)'; return 'INDEX "select" (foo)';
} }
/**
* {@inheritdoc}
*/
protected function getAlterStringToFixedStringSQL()
{
return array(
'CREATE TEMPORARY TABLE __temp__mytable AS SELECT name FROM mytable',
'DROP TABLE mytable',
'CREATE TABLE mytable (name CHAR(2) NOT NULL)',
'INSERT INTO mytable (name) SELECT name FROM __temp__mytable',
'DROP TABLE __temp__mytable',
);
}
} }
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