[Pkg-owncloud-commits] [owncloud] 57/457: Add unit test for migrator with different prefix

David Prévot taffit at moszumanska.debian.org
Sun Jun 28 20:05:25 UTC 2015


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

taffit pushed a commit to branch stable8
in repository owncloud.

commit fabdc4ba9dd13491aeef5affb68326937e3483e5
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Mon May 18 16:57:59 2015 +0200

    Add unit test for migrator with different prefix
---
 tests/lib/db/migrator.php | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/tests/lib/db/migrator.php b/tests/lib/db/migrator.php
index 5426774..6bde68c 100644
--- a/tests/lib/db/migrator.php
+++ b/tests/lib/db/migrator.php
@@ -26,11 +26,17 @@ class Migrator extends \Test\TestCase {
 	 */
 	private $manager;
 
+	/**
+	 * @var IConfig
+	 **/
+	private $config;
+
 	private $tableName;
 
 	protected function setUp() {
 		parent::setUp();
 
+		$this->config = \OC::$server->getConfig();
 		$this->connection = \OC_DB::getConnection();
 		if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) {
 			$this->markTestSkipped('DB migration tests are not supported on OCI');
@@ -39,7 +45,7 @@ class Migrator extends \Test\TestCase {
 			$this->markTestSkipped('DB migration tests are not supported on MSSQL');
 		}
 		$this->manager = new \OC\DB\MDB2SchemaManager($this->connection);
-		$this->tableName = strtolower($this->getUniqueID('oc_test_'));
+		$this->tableName = strtolower($this->getUniqueID($this->config->getSystemValue('dbtableprefix', 'oc_') . 'test_'));
 	}
 
 	protected function tearDown() {
@@ -109,6 +115,27 @@ class Migrator extends \Test\TestCase {
 		$this->assertTrue(true);
 	}
 
+	public function testUpgradeDifferentPrefix() {
+		$oldTablePrefix = $this->config->getSystemValue('dbtableprefix', 'oc_');
+
+		$this->config->setSystemValue('dbtableprefix', 'ownc_');
+		$this->tableName = strtolower($this->getUniqueID($this->config->getSystemValue('dbtableprefix') . 'test_'));
+
+		list($startSchema, $endSchema) = $this->getDuplicateKeySchemas();
+		$migrator = $this->manager->getMigrator();
+		$migrator->migrate($startSchema);
+
+		$this->connection->insert($this->tableName, array('id' => 1, 'name' => 'foo'));
+		$this->connection->insert($this->tableName, array('id' => 2, 'name' => 'bar'));
+		$this->connection->insert($this->tableName, array('id' => 3, 'name' => 'qwerty'));
+
+		$migrator->checkMigrate($endSchema);
+		$migrator->migrate($endSchema);
+		$this->assertTrue(true);
+
+		$this->config->setSystemValue('dbtableprefix', $oldTablePrefix);
+	}
+
 	public function testInsertAfterUpgrade() {
 		list($startSchema, $endSchema) = $this->getDuplicateKeySchemas();
 		$migrator = $this->manager->getMigrator();

-- 
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