You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mdb2schemamanager.php 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Copyright (c) 2014 Thomas Müller <deepdiver@owncloud.com>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. namespace Test\DB;
  9. use Doctrine\DBAL\Platforms\OraclePlatform;
  10. use Doctrine\DBAL\Platforms\SQLServerPlatform;
  11. class MDB2SchemaManager extends \Test\TestCase {
  12. protected function tearDown() {
  13. // do not drop the table for Oracle as it will create a bogus transaction
  14. // that will break the following test suites requiring transactions
  15. if (\OC::$server->getConfig()->getSystemValue('dbtype', 'sqlite') === 'oci') {
  16. return;
  17. }
  18. \OC_DB::dropTable('table');
  19. parent::tearDown();
  20. }
  21. public function testAutoIncrement() {
  22. $connection = \OC_DB::getConnection();
  23. if ($connection->getDatabasePlatform() instanceof OraclePlatform) {
  24. $this->markTestSkipped('Adding auto increment columns in Oracle is not supported.');
  25. }
  26. if ($connection->getDatabasePlatform() instanceof SQLServerPlatform) {
  27. $this->markTestSkipped('DB migration tests are not supported on MSSQL');
  28. }
  29. $manager = new \OC\DB\MDB2SchemaManager($connection);
  30. $manager->createDbFromStructure(__DIR__ . '/ts-autoincrement-before.xml');
  31. $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('abc'));
  32. $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('abc'));
  33. $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('123'));
  34. $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('123'));
  35. $manager->updateDbFromStructure(__DIR__ . '/ts-autoincrement-after.xml');
  36. $this->assertTrue(true);
  37. }
  38. }