summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-04-17 16:12:48 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2014-06-06 13:33:56 +0200
commitfe8bae31dc80ac832323fa8d9a75fd4b543d36e0 (patch)
treefedada14b0c6e7ad32fa588f438aa0e1cf243045 /tests
parentc47d4ebbac7885ad91cf56355bd6aa09318ff8e8 (diff)
downloadnextcloud-server-fe8bae31dc80ac832323fa8d9a75fd4b543d36e0.tar.gz
nextcloud-server-fe8bae31dc80ac832323fa8d9a75fd4b543d36e0.zip
adding PK to table encryption
adding auto increment/PK to table files_trash adding PK to table ldap_user_mapping and ldap_group_members adding PK to table ldap_group_mapping truncate permissions table to allow smooth creation of primary key adding unit test for creating an auto increment column on a table which already contains data remove unneeded table files_trashsizes fix unit test no need to truncate *PREFIX*permissions On Oracle adding auto increment columns is not working out of the box - Oracle migrations are to be done manually
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/db/mdb2schemamanager.php37
-rw-r--r--tests/lib/db/ts-autoincrement-after.xml32
-rw-r--r--tests/lib/db/ts-autoincrement-before.xml24
3 files changed, 93 insertions, 0 deletions
diff --git a/tests/lib/db/mdb2schemamanager.php b/tests/lib/db/mdb2schemamanager.php
new file mode 100644
index 00000000000..51e3c7002f4
--- /dev/null
+++ b/tests/lib/db/mdb2schemamanager.php
@@ -0,0 +1,37 @@
+<?php
+
+/**
+ * Copyright (c) 2014 Thomas Müller <deepdiver@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test\DB;
+
+class MDB2SchemaManager extends \PHPUnit_Framework_TestCase {
+
+ public function tearDown() {
+ \OC_DB::dropTable('table');
+ }
+
+ public function testAutoIncrement() {
+
+ if (\OC::$server->getConfig()->getSystemValue('dbtype', 'sqlite') === 'oci') {
+ $this->markTestSkipped('Adding auto increment columns in Oracle is not supported.');
+ }
+
+ $connection = \OC_DB::getConnection();
+ $manager = new \OC\DB\MDB2SchemaManager($connection);
+
+ $manager->createDbFromStructure(__DIR__ . '/ts-autoincrement-before.xml');
+ $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('abc'));
+ $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('abc'));
+ $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('123'));
+ $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('123'));
+ $manager->updateDbFromStructure(__DIR__ . '/ts-autoincrement-after.xml');
+
+ $this->assertTrue(true);
+ }
+
+}
diff --git a/tests/lib/db/ts-autoincrement-after.xml b/tests/lib/db/ts-autoincrement-after.xml
new file mode 100644
index 00000000000..d4445f1e247
--- /dev/null
+++ b/tests/lib/db/ts-autoincrement-after.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<database>
+
+ <name>*dbname*</name>
+ <create>true</create>
+ <overwrite>false</overwrite>
+
+ <charset>utf8</charset>
+
+ <table>
+
+ <name>*dbprefix*table</name>
+
+ <declaration>
+ <field>
+ <name>auto_id</name>
+ <type>integer</type>
+ <default>0</default>
+ <notnull>true</notnull>
+ <autoincrement>1</autoincrement>
+ <length>4</length>
+ </field>
+ <field>
+ <name>textfield</name>
+ <type>text</type>
+ <default>foo</default>
+ <notnull>true</notnull>
+ <length>32</length>
+ </field>
+ </declaration>
+ </table>
+</database>
diff --git a/tests/lib/db/ts-autoincrement-before.xml b/tests/lib/db/ts-autoincrement-before.xml
new file mode 100644
index 00000000000..412739e9a71
--- /dev/null
+++ b/tests/lib/db/ts-autoincrement-before.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<database>
+
+ <name>*dbname*</name>
+ <create>true</create>
+ <overwrite>false</overwrite>
+
+ <charset>utf8</charset>
+
+ <table>
+
+ <name>*dbprefix*table</name>
+
+ <declaration>
+ <field>
+ <name>textfield</name>
+ <type>text</type>
+ <default>foo</default>
+ <notnull>true</notnull>
+ <length>32</length>
+ </field>
+ </declaration>
+ </table>
+</database>