DropOldTablesTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * Copyright (c) 2015 Joas Schilling <nickvergessen@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\Repair;
  9. use OCP\Migration\IOutput;
  10. /**
  11. * Tests for the dropping old tables
  12. *
  13. * @group DB
  14. *
  15. * @see \OC\Repair\DropOldTables
  16. */
  17. class DropOldTablesTest extends \Test\TestCase {
  18. /** @var \OCP\IDBConnection */
  19. protected $connection;
  20. protected function setUp() {
  21. parent::setUp();
  22. $this->connection = \OC::$server->getDatabaseConnection();
  23. $manager = new \OC\DB\MDB2SchemaManager($this->connection);
  24. $manager->createDbFromStructure(__DIR__ . '/fixtures/dropoldtables.xml');
  25. }
  26. public function testRun() {
  27. $this->assertFalse($this->connection->tableExists('sharing'), 'Asserting that the table oc_sharing does not exist before repairing');
  28. $this->assertTrue($this->connection->tableExists('permissions'), 'Asserting that the table oc_permissions does exist before repairing');
  29. /** @var IOutput | \PHPUnit_Framework_MockObject_MockObject $outputMock */
  30. $outputMock = $this->getMockBuilder('\OCP\Migration\IOutput')
  31. ->disableOriginalConstructor()
  32. ->getMock();
  33. $repair = new \OC\Repair\DropOldTables($this->connection);
  34. $repair->run($outputMock);
  35. $this->assertFalse($this->connection->tableExists('sharing'), 'Asserting that the table oc_sharing does not exist after repairing');
  36. $this->assertFalse($this->connection->tableExists('permissions'), 'Asserting that the table oc_permissions does not exist after repairing');
  37. }
  38. }