summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/DB/OCPostgreSqlPlatformTest.php74
-rw-r--r--tests/lib/Repair/RepairInvalidPathsTest.php30
2 files changed, 104 insertions, 0 deletions
diff --git a/tests/lib/DB/OCPostgreSqlPlatformTest.php b/tests/lib/DB/OCPostgreSqlPlatformTest.php
new file mode 100644
index 00000000000..56fab621cfc
--- /dev/null
+++ b/tests/lib/DB/OCPostgreSqlPlatformTest.php
@@ -0,0 +1,74 @@
+<?php
+/**
+ * @author Victor Dubiniuk <dubiniuk@owncloud.com>
+ *
+ * @copyright Copyright (c) 2017, ownCloud GmbH
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace Test\DB;
+
+use Doctrine\DBAL\Schema\Comparator;
+use Doctrine\DBAL\Schema\Schema;
+use Doctrine\DBAL\Schema\TableDiff;
+use Doctrine\DBAL\Types\Type;
+use OC\DB\OCPostgreSqlPlatform;
+
+ /**
+ * Class OCPostgreSqlPlatformTest
+ *
+ * @group DB
+ *
+ * @package Test\DB
+ */
+
+class OCPostgreSqlPlatformTest extends \Test\TestCase {
+
+ public function testAlterBigint(){
+ $platform = new OCPostgreSqlPlatform();
+ $sourceSchema = new Schema();
+ $targetSchema = new Schema();
+
+ $this->createTableAndColumn($sourceSchema, Type::INTEGER);
+ $this->createTableAndColumn($targetSchema, Type::BIGINT);
+
+ $comparator = new Comparator();
+ $diff = $comparator->compare($sourceSchema, $targetSchema);
+ $sqlStatements = $diff->toSql($platform);
+ $this->assertContains(
+ 'ALTER TABLE poor_yorick ALTER id TYPE BIGINT',
+ $sqlStatements,
+ true
+ );
+
+ $this->assertNotContains(
+ 'ALTER TABLE poor_yorick ALTER id DROP DEFAULT',
+ $sqlStatements,
+ true
+ );
+ }
+
+ protected function createTableAndColumn($schema, $type){
+ $table = $schema->createTable("poor_yorick");
+ $table->addColumn('id', $type, [
+ 'autoincrement' => true,
+ 'unsigned' => true,
+ 'notnull' => true,
+ 'length' => 11,
+ ]);
+ }
+
+}
diff --git a/tests/lib/Repair/RepairInvalidPathsTest.php b/tests/lib/Repair/RepairInvalidPathsTest.php
index b0370f5ae2d..17c584fd149 100644
--- a/tests/lib/Repair/RepairInvalidPathsTest.php
+++ b/tests/lib/Repair/RepairInvalidPathsTest.php
@@ -186,4 +186,34 @@ class RepairInvalidPathsTest extends TestCase {
$this->assertEquals($folderId, $this->cache2->get('foo2/bar/asd')['parent']);
$this->assertEquals($folderId, $this->cache2->getId('foo2/bar'));
}
+
+ public function shouldRunDataProvider() {
+ return [
+ ['11.0.0.0', true],
+ ['11.0.0.31', true],
+ ['11.0.5.2', false],
+ ['12.0.0.0', true],
+ ['12.0.0.1', true],
+ ['12.0.0.31', false],
+ ['13.0.0.0', true],
+ ['13.0.0.1', false]
+ ];
+ }
+
+ /**
+ * @dataProvider shouldRunDataProvider
+ *
+ * @param string $from
+ * @param boolean $expected
+ */
+ public function testShouldRun($from, $expected) {
+ $config = $this->createMock(IConfig::class);
+ $config->expects($this->any())
+ ->method('getSystemValue')
+ ->with('version', '0.0.0')
+ ->willReturn($from);
+ $repair = new RepairInvalidPaths(\OC::$server->getDatabaseConnection(), $config);
+
+ $this->assertEquals($expected, $this->invokePrivate($repair, 'shouldRun'));
+ }
}