1
0
mirror of synced 2024-12-12 22:36:02 +03:00

[2.0] DDC-169 - Refactored Parts of the Platform Tests into an Abstract Test Case

This commit is contained in:
beberlei 2009-12-05 23:06:29 +00:00
parent 8bfde41374
commit 4736f5ee50
6 changed files with 38 additions and 62 deletions

View File

@ -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.");
}
}
}

View File

@ -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',
);
}

View File

@ -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',
);
}

View File

@ -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]
);
}

View File

@ -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]
);
}

View File

@ -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.');
}
}