Fix migrator tests to use the correct migrator instances
This commit is contained in:
parent
88e6f5c318
commit
b752aff51d
2 changed files with 11 additions and 13 deletions
|
@ -58,7 +58,7 @@ class MDB2SchemaManager {
|
|||
/**
|
||||
* @return \OC\DB\Migrator
|
||||
*/
|
||||
protected function getMigrator() {
|
||||
public function getMigrator() {
|
||||
$platform = $this->conn->getDatabasePlatform();
|
||||
if ($platform instanceof SqlitePlatform) {
|
||||
return new SQLiteMigrator($this->conn);
|
||||
|
|
|
@ -19,6 +19,11 @@ class Migrator extends \PHPUnit_Framework_TestCase {
|
|||
*/
|
||||
private $connection;
|
||||
|
||||
/**
|
||||
* @var \OC\DB\MDB2SchemaManager
|
||||
*/
|
||||
private $manager;
|
||||
|
||||
private $tableName;
|
||||
|
||||
public function setUp() {
|
||||
|
@ -26,6 +31,7 @@ class Migrator extends \PHPUnit_Framework_TestCase {
|
|||
if ($this->connection->getDriver() instanceof \Doctrine\DBAL\Driver\OCI8\Driver) {
|
||||
$this->markTestSkipped('DB migration tests arent supported on OCI');
|
||||
}
|
||||
$this->manager = new \OC\DB\MDB2SchemaManager($this->connection);
|
||||
$this->tableName = 'test_' . uniqid();
|
||||
}
|
||||
|
||||
|
@ -62,14 +68,6 @@ class Migrator extends \PHPUnit_Framework_TestCase {
|
|||
return $this->connection->getDriver() instanceof \Doctrine\DBAL\Driver\PDOSqlite\Driver;
|
||||
}
|
||||
|
||||
private function getMigrator() {
|
||||
if ($this->isSQLite()) {
|
||||
return new \OC\DB\SQLiteMigrator($this->connection);
|
||||
} else {
|
||||
return new \OC\DB\Migrator($this->connection);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \OC\DB\MigrationException
|
||||
*/
|
||||
|
@ -78,7 +76,7 @@ class Migrator extends \PHPUnit_Framework_TestCase {
|
|||
$this->markTestSkipped('sqlite doesnt throw errors when creating a new key on existing data');
|
||||
}
|
||||
list($startSchema, $endSchema) = $this->getDuplicateKeySchemas();
|
||||
$migrator = $this->getMigrator();
|
||||
$migrator = $this->manager->getMigrator();
|
||||
$migrator->migrate($startSchema);
|
||||
|
||||
$this->connection->insert($this->tableName, array('id' => 1, 'name' => 'foo'));
|
||||
|
@ -91,7 +89,7 @@ class Migrator extends \PHPUnit_Framework_TestCase {
|
|||
|
||||
public function testUpgrade() {
|
||||
list($startSchema, $endSchema) = $this->getDuplicateKeySchemas();
|
||||
$migrator = $this->getMigrator();
|
||||
$migrator = $this->manager->getMigrator();
|
||||
$migrator->migrate($startSchema);
|
||||
|
||||
$this->connection->insert($this->tableName, array('id' => 1, 'name' => 'foo'));
|
||||
|
@ -105,7 +103,7 @@ class Migrator extends \PHPUnit_Framework_TestCase {
|
|||
|
||||
public function testInsertAfterUpgrade() {
|
||||
list($startSchema, $endSchema) = $this->getDuplicateKeySchemas();
|
||||
$migrator = $this->getMigrator();
|
||||
$migrator = $this->manager->getMigrator();
|
||||
$migrator->migrate($startSchema);
|
||||
|
||||
$migrator->migrate($endSchema);
|
||||
|
@ -132,7 +130,7 @@ class Migrator extends \PHPUnit_Framework_TestCase {
|
|||
$table->addColumn('name', 'string');
|
||||
$table->setPrimaryKey(array('id'));
|
||||
|
||||
$migrator = $this->getMigrator();
|
||||
$migrator = $this->manager->getMigrator();
|
||||
$migrator->migrate($startSchema);
|
||||
|
||||
$migrator->checkMigrate($endSchema);
|
||||
|
|
Loading…
Reference in a new issue