diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/DB/MigratorTest.php | 49 | ||||
-rw-r--r-- | tests/lib/Preview/Provider.php | 4 | ||||
-rw-r--r-- | tests/lib/Share20/ManagerTest.php | 6 |
3 files changed, 59 insertions, 0 deletions
diff --git a/tests/lib/DB/MigratorTest.php b/tests/lib/DB/MigratorTest.php index b5021dcccf9..52b0b0ff03e 100644 --- a/tests/lib/DB/MigratorTest.php +++ b/tests/lib/DB/MigratorTest.php @@ -13,6 +13,7 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Platforms\OraclePlatform; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\SchemaConfig; +use OC\DB\SchemaWrapper; use OCP\IConfig; /** @@ -94,6 +95,26 @@ class MigratorTest extends \Test\TestCase { return [$startSchema, $endSchema]; } + /** + * @return \Doctrine\DBAL\Schema\Schema[] + */ + private function getChangedTypeSchema($from, $to) { + $startSchema = new Schema([], [], $this->getSchemaConfig()); + $table = $startSchema->createTable($this->tableName); + $table->addColumn('id', $from); + $table->addColumn('name', 'string'); + $table->addIndex(['id'], $this->tableName . '_id'); + + $endSchema = new Schema([], [], $this->getSchemaConfig()); + $table = $endSchema->createTable($this->tableName); + $table->addColumn('id', $to); + $table->addColumn('name', 'string'); + $table->addIndex(['id'], $this->tableName . '_id'); + + return [$startSchema, $endSchema]; + } + + private function getSchemaConfig() { $config = new SchemaConfig(); $config->setName($this->connection->getDatabase()); @@ -123,6 +144,34 @@ class MigratorTest extends \Test\TestCase { $this->fail('checkMigrate should have failed'); } + public function testChangeToString() { + list($startSchema, $endSchema) = $this->getChangedTypeSchema('integer', 'string'); + $migrator = $this->manager->getMigrator(); + $migrator->migrate($startSchema); + $schema = new SchemaWrapper($this->connection); + $table = $schema->getTable(substr($this->tableName, 3)); + $this->assertEquals('integer', $table->getColumn('id')->getType()->getName()); + + $this->connection->insert($this->tableName, ['id' => 1, 'name' => 'foo']); + $this->connection->insert($this->tableName, ['id' => 2, 'name' => 'bar']); + $this->connection->insert($this->tableName, ['id' => 3, 'name' => 'qwerty']); + + $migrator->checkMigrate($endSchema); + $migrator->migrate($endSchema); + $this->addToAssertionCount(1); + + $qb = $this->connection->getQueryBuilder(); + $result = $qb->select('*')->from(substr($this->tableName, 3))->execute(); + $this->assertEquals([ + ['id' => 1, 'name' => 'foo'], + ['id' => 2, 'name' => 'bar'], + ['id' => 3, 'name' => 'qwerty'] + ], $result->fetchAll()); + $schema = new SchemaWrapper($this->connection); + $table = $schema->getTable(substr($this->tableName, 3)); + $this->assertEquals('string', $table->getColumn('id')->getType()->getName()); + } + public function testUpgrade() { list($startSchema, $endSchema) = $this->getDuplicateKeySchemas(); $migrator = $this->manager->getMigrator(); diff --git a/tests/lib/Preview/Provider.php b/tests/lib/Preview/Provider.php index 761f6b7f83f..90287116512 100644 --- a/tests/lib/Preview/Provider.php +++ b/tests/lib/Preview/Provider.php @@ -141,6 +141,10 @@ abstract class Provider extends \Test\TestCase { $file = new File(\OC::$server->getRootFolder(), $this->rootView, $this->imgPath); $preview = $provider->getThumbnail($file, $this->maxWidth, $this->maxHeight, $this->scalingUp); + if (get_class($this) === BitmapTest::class && $preview === null) { + $this->markTestSkipped('An error occured while operating with Imagick.'); + } + $this->assertNotEquals(false, $preview); $this->assertEquals(true, $preview->valid()); diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php index 65313858c01..efae909b99f 100644 --- a/tests/lib/Share20/ManagerTest.php +++ b/tests/lib/Share20/ManagerTest.php @@ -4362,6 +4362,9 @@ class DummyFactory implements IProviderFactory { public function getAllProviders() { return [$this->provider]; } + + public function registerProvider(string $shareProvier): void { + } } class DummyFactory2 extends DummyFactory { @@ -4378,4 +4381,7 @@ class DummyFactory2 extends DummyFactory { public function getAllProviders() { return [$this->provider, $this->provider2]; } + + public function registerProvider(string $shareProvier): void { + } } |