Commit 18d5b5f9 authored by Claudio Zizza's avatar Claudio Zizza Committed by Steve Müller

unittest adapted for all plattforms using AbstractPlatformTestCase

parent 0ac889b4
......@@ -514,4 +514,35 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
implode(';', $this->_platform->getAlterTableSQL($tableDiff))
);
}
/**
* @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();
}
......@@ -378,4 +378,14 @@ class MySqlPlatformTest extends AbstractPlatformTestCase
"ALTER TABLE mytable ADD PRIMARY KEY (foo)",
), $sql);
}
/**
* {@inheritdoc}
*/
protected function getAlterStringToFixedStringSQL()
{
return array(
'ALTER TABLE mytable CHANGE name name CHAR(2) NOT NULL',
);
}
}
......@@ -330,4 +330,14 @@ class OraclePlatformTest extends AbstractPlatformTestCase
);
$this->assertEquals($expectedSql, $this->_platform->getAlterTableSQL($tableDiff));
}
/**
* {@inheritdoc}
*/
protected function getAlterStringToFixedStringSQL()
{
return array(
'ALTER TABLE mytable MODIFY (name CHAR(2) DEFAULT NULL)',
);
}
}
......@@ -487,29 +487,11 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
/**
* @group DBAL-1090
*/
public function testAlterStringToFixedString()
protected function getAlterStringToFixedStringSQL()
{
$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(
return array(
'ALTER TABLE mytable ALTER name TYPE CHAR(2)',
);
$this->assertEquals($expectedSql, $sql);
}
}
......@@ -343,4 +343,14 @@ class SQLServerPlatformTest extends AbstractPlatformTestCase
array(LockMode::PESSIMISTIC_WRITE, ' WITH (UPDLOCK, ROWLOCK)'),
);
}
/**
* {@inheritdoc}
*/
protected function getAlterStringToFixedStringSQL()
{
return array(
'ALTER TABLE mytable ALTER COLUMN name NCHAR(2) NOT NULL',
);
}
}
......@@ -302,4 +302,18 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
'CONSTRAINT FK_WITH_INTENDED_QUOTATION FOREIGN KEY ("create", foo, "bar") REFERENCES "foo-bar" ("create", bar, "foo-bar") NOT DEFERRABLE INITIALLY IMMEDIATE)',
);
}
/**
* {@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