[2.0] DDC-169 - Refactored Parts of the Platform Tests into an Abstract Test Case
This commit is contained in:
parent
8bfde41374
commit
4736f5ee50
@ -88,4 +88,27 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
|
||||
{
|
||||
return 'ALTER TABLE test ADD CONSTRAINT constraint_fk FOREIGN KEY (fk_name) REFERENCES foreign (id)';
|
||||
}
|
||||
|
||||
abstract public function getGenerateAlterTableSql();
|
||||
|
||||
public function testGeneratesTableAlterationSqlForAddingAndRenaming()
|
||||
{
|
||||
$expectedSql = $this->getGenerateAlterTableSql();
|
||||
|
||||
$changes = array(
|
||||
'name' => 'userlist',
|
||||
'add' => array(
|
||||
'quota' => array(
|
||||
'type' => \Doctrine\DBAL\Types\Type::getType('integer'),
|
||||
'notnull' => false,
|
||||
)
|
||||
));
|
||||
|
||||
$sql = $this->_platform->getAlterTableSql('mytable', $changes);
|
||||
|
||||
$this->assertEquals(count($sql), count($expectedSql), "Expecting the same number of sql queries for alter table failed.");
|
||||
for ($i = 0; $i < count($expectedSql); $i++) {
|
||||
$this->assertEquals($expectedSql[$i], $sql[$i], $i."th query of alter table does not match.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,21 +19,10 @@ class MsSqlPlatformTest extends AbstractPlatformTestCase
|
||||
return 'CREATE TABLE test (id INT AUTO_INCREMENT NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))';
|
||||
}
|
||||
|
||||
public function testGeneratesTableAlterationSql()
|
||||
public function getGenerateAlterTableSql()
|
||||
{
|
||||
$changes = array(
|
||||
'name' => 'userlist',
|
||||
'add' => array(
|
||||
'quota' => array(
|
||||
'type' => Type::getType('integer'),
|
||||
'unsigned' => 1
|
||||
)
|
||||
));
|
||||
|
||||
$sql = $this->_platform->getAlterTableSql('mytable', $changes);
|
||||
$this->assertEquals(
|
||||
'ALTER TABLE mytable RENAME TO userlist, ADD quota INT UNSIGNED DEFAULT NULL',
|
||||
$sql[0]
|
||||
return array(
|
||||
'ALTER TABLE mytable RENAME TO userlist, ADD quota INT DEFAULT NULL',
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -28,21 +28,10 @@ class MySqlPlatformTest extends AbstractPlatformTestCase
|
||||
return 'CREATE TABLE test (id INT AUTO_INCREMENT NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) ENGINE = InnoDB';
|
||||
}
|
||||
|
||||
public function testGeneratesTableAlterationSql()
|
||||
public function getGenerateAlterTableSql()
|
||||
{
|
||||
$changes = array(
|
||||
'name' => 'userlist',
|
||||
'add' => array(
|
||||
'quota' => array(
|
||||
'type' => Type::getType('integer'),
|
||||
'unsigned' => 1
|
||||
)
|
||||
));
|
||||
|
||||
$sql = $this->_platform->getAlterTableSql('mytable', $changes);
|
||||
$this->assertEquals(
|
||||
'ALTER TABLE mytable RENAME TO userlist, ADD quota INT UNSIGNED DEFAULT NULL',
|
||||
$sql[0]
|
||||
return array(
|
||||
'ALTER TABLE mytable RENAME TO userlist, ADD quota INT DEFAULT NULL',
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -19,27 +19,11 @@ class OraclePlatformTest extends AbstractPlatformTestCase
|
||||
return 'CREATE TABLE test (id NUMBER(10) NOT NULL, test VARCHAR2(255) DEFAULT NULL, PRIMARY KEY(id))';
|
||||
}
|
||||
|
||||
public function testGeneratesTableAlterationSql()
|
||||
public function getGenerateAlterTableSql()
|
||||
{
|
||||
$changes = array(
|
||||
'name' => 'userlist',
|
||||
'add' => array(
|
||||
'quota' => array(
|
||||
'type' => Type::getType('integer'),
|
||||
'unsigned' => 1
|
||||
)
|
||||
));
|
||||
|
||||
$sql = $this->_platform->getAlterTableSql('mytable', $changes);
|
||||
|
||||
$this->assertEquals(
|
||||
return array(
|
||||
'ALTER TABLE mytable ADD (quota NUMBER(10) DEFAULT NULL)',
|
||||
$sql[0]
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
'ALTER TABLE mytable RENAME TO userlist',
|
||||
$sql[1]
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -20,25 +20,11 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
|
||||
return 'CREATE TABLE test (id SERIAL NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))';
|
||||
}
|
||||
|
||||
public function testGeneratesTableAlterationSqlForAddingAndRenaming()
|
||||
public function getGenerateAlterTableSql()
|
||||
{
|
||||
$changes = array(
|
||||
'name' => 'userlist',
|
||||
'add' => array(
|
||||
'quota' => array(
|
||||
'type' => Type::getType('integer')
|
||||
)
|
||||
));
|
||||
|
||||
$sql = $this->_platform->getAlterTableSql('mytable', $changes);
|
||||
|
||||
$this->assertEquals(
|
||||
return array(
|
||||
'ALTER TABLE mytable ADD quota INT DEFAULT NULL',
|
||||
$sql[0]
|
||||
);
|
||||
$this->assertEquals(
|
||||
'ALTER TABLE mytable RENAME TO userlist',
|
||||
$sql[1]
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -101,4 +101,9 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
|
||||
$sql = $this->_platform->modifyLimitQuery('SELECT * FROM user', 10);
|
||||
$this->assertEquals('SELECT * FROM user LIMIT 10', $sql);
|
||||
}
|
||||
|
||||
public function getGenerateAlterTableSql()
|
||||
{
|
||||
$this->markTestSkipped('SQlite does not support ALTER Table.');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user