[Pkg-owncloud-commits] [owncloud] 38/61: migration test for sqlite - adding type mapping for 'tinyint unsigned'

David Prévot taffit at moszumanska.debian.org
Thu Jul 31 03:51:46 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit dc41f63930648531c17d39ad38ab191b0c9da66b
Author: Thomas Müller <thomas.mueller at tmit.eu>
Date:   Fri Jul 25 08:46:43 2014 +0200

    migration test for sqlite - adding type mapping for 'tinyint unsigned'
---
 lib/private/db/sqlitemigrator.php                   | 13 +++++++++++++
 tests/lib/db/{migration.php => mysqlmigration.php}  |  2 +-
 tests/lib/db/{migration.php => sqlitemigration.php} |  8 ++++----
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/lib/private/db/sqlitemigrator.php b/lib/private/db/sqlitemigrator.php
index 81bbcb5..94b421c 100644
--- a/lib/private/db/sqlitemigrator.php
+++ b/lib/private/db/sqlitemigrator.php
@@ -9,6 +9,7 @@
 namespace OC\DB;
 
 use Doctrine\DBAL\DBALException;
+use Doctrine\DBAL\Schema\Schema;
 
 class SQLiteMigrator extends Migrator {
 
@@ -61,4 +62,16 @@ class SQLiteMigrator extends Migrator {
 		$tmpFile = uniqid("oc_");
 		return "$dataDir/$tmpFile.db";
 	}
+
+	/**
+	 * @param Schema $targetSchema
+	 * @param \Doctrine\DBAL\Connection $connection
+	 * @return \Doctrine\DBAL\Schema\SchemaDiff
+	 */
+	protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) {
+		$platform = $connection->getDatabasePlatform();
+		$platform->registerDoctrineTypeMapping('tinyint unsigned', 'integer');
+
+		return parent::getDiff($targetSchema, $connection);
+	}
 }
diff --git a/tests/lib/db/migration.php b/tests/lib/db/mysqlmigration.php
similarity index 94%
copy from tests/lib/db/migration.php
copy to tests/lib/db/mysqlmigration.php
index 820a143..584df1d 100644
--- a/tests/lib/db/migration.php
+++ b/tests/lib/db/mysqlmigration.php
@@ -6,7 +6,7 @@
  * See the COPYING-README file.
  */
 
-class TestMigration extends \PHPUnit_Framework_TestCase {
+class TestMySqlMigration extends \PHPUnit_Framework_TestCase {
 
 	/** @var \Doctrine\DBAL\Connection */
 	private $connection;
diff --git a/tests/lib/db/migration.php b/tests/lib/db/sqlitemigration.php
similarity index 77%
rename from tests/lib/db/migration.php
rename to tests/lib/db/sqlitemigration.php
index 820a143..adfc03a 100644
--- a/tests/lib/db/migration.php
+++ b/tests/lib/db/sqlitemigration.php
@@ -6,7 +6,7 @@
  * See the COPYING-README file.
  */
 
-class TestMigration extends \PHPUnit_Framework_TestCase {
+class TestSqliteMigration extends \PHPUnit_Framework_TestCase {
 
 	/** @var \Doctrine\DBAL\Connection */
 	private $connection;
@@ -16,13 +16,13 @@ class TestMigration extends \PHPUnit_Framework_TestCase {
 
 	public function setUp() {
 		$this->connection = \OC_DB::getConnection();
-		if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) {
-			$this->markTestSkipped("Test only relevant on MySql");
+		if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
+			$this->markTestSkipped("Test only relevant on Sqlite");
 		}
 
 		$dbPrefix = \OC::$server->getConfig()->getSystemValue("dbtableprefix");
 		$this->tableName = uniqid($dbPrefix . "_enum_bit_test");
-		$this->connection->exec("CREATE TABLE $this->tableName(b BIT,  e ENUM('1','2','3','4'))");
+		$this->connection->exec("CREATE TABLE $this->tableName(t0 tinyint unsigned, t1 tinyint)");
 	}
 
 	public function tearDown() {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list