diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-07-01 12:54:35 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-07-01 12:54:35 +0200 |
commit | b752aff51d4bfea37a52bd832c3d645996e6dd8d (patch) | |
tree | 01e8f7d64455a8aea1f4f0f9a63d8ae0712a565f /tests | |
parent | 88e6f5c318d1fcd08ac2182bbfbdf9b15ae34d17 (diff) | |
download | nextcloud-server-b752aff51d4bfea37a52bd832c3d645996e6dd8d.tar.gz nextcloud-server-b752aff51d4bfea37a52bd832c3d645996e6dd8d.zip |
Fix migrator tests to use the correct migrator instances
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/db/migrator.php | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/tests/lib/db/migrator.php b/tests/lib/db/migrator.php index e94d550f836..aa9c96841ff 100644 --- a/tests/lib/db/migrator.php +++ b/tests/lib/db/migrator.php @@ -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); |