MDB2SchemaManagerTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. /**
  11. * Class MDB2SchemaManager
  12. *
  13. * @group DB
  14. *
  15. * @package Test\DB
  16. */
  17. class MDB2SchemaManagerTest extends \Test\TestCase {
  18. protected function tearDown() {
  19. // do not drop the table for Oracle as it will create a bogus transaction
  20. // that will break the following test suites requiring transactions
  21. if (\OC::$server->getConfig()->getSystemValue('dbtype', 'sqlite') !== 'oci') {
  22. \OC::$server->getDatabaseConnection()->dropTable('table');
  23. }
  24. parent::tearDown();
  25. }
  26. public function testAutoIncrement() {
  27. $connection = \OC::$server->getDatabaseConnection();
  28. if ($connection->getDatabasePlatform() instanceof OraclePlatform) {
  29. $this->markTestSkipped('Adding auto increment columns in Oracle is not supported.');
  30. }
  31. $manager = new \OC\DB\MDB2SchemaManager($connection);
  32. $manager->createDbFromStructure(__DIR__ . '/ts-autoincrement-before.xml');
  33. $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('abc'));
  34. $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('abc'));
  35. $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('123'));
  36. $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('123'));
  37. $manager->updateDbFromStructure(__DIR__ . '/ts-autoincrement-after.xml');
  38. $this->assertTrue(true);
  39. }
  40. }