Skip to content

Commit b8d4df4

Browse files
committed
refactor(tests): teardown is now always called - also when skipped
* ref: sebastianbergmann/phpunit#6394 Signed-off-by: Ferdinand Thiessen <[email protected]>
1 parent 3c727f8 commit b8d4df4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tests/lib/Repair/RepairCollationTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public function getAllNonUTF8BinTables(IDBConnection $connection) {
3131
/**
3232
* Tests for the converting of MySQL tables to InnoDB engine
3333
*
34-
*
3534
* @see \OC\Repair\RepairMimeTypes
3635
*/
3736
#[\PHPUnit\Framework\Attributes\Group('DB')]
@@ -48,13 +47,12 @@ protected function setUp(): void {
4847
parent::setUp();
4948

5049
$this->connection = Server::get(ConnectionAdapter::class);
51-
$this->config = Server::get(IConfig::class);
5250
if ($this->connection->getDatabaseProvider() !== IDBConnection::PLATFORM_MYSQL) {
5351
$this->markTestSkipped('Test only relevant on MySql');
5452
}
5553

5654
$this->logger = $this->createMock(LoggerInterface::class);
57-
55+
$this->config = Server::get(IConfig::class);
5856
$dbPrefix = $this->config->getSystemValueString('dbtableprefix');
5957
$this->tableName = $this->getUniqueID($dbPrefix . '_collation_test');
6058
$this->connection->prepare("CREATE TABLE $this->tableName(text VARCHAR(16)) COLLATE utf8_unicode_ci")->execute();
@@ -63,7 +61,11 @@ protected function setUp(): void {
6361
}
6462

6563
protected function tearDown(): void {
66-
$this->connection->getInner()->createSchemaManager()->dropTable($this->tableName);
64+
$this->connection = Server::get(ConnectionAdapter::class);
65+
if ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_MYSQL) {
66+
// tear down only needed on MySQL
67+
$this->connection->getInner()->createSchemaManager()->dropTable($this->tableName);
68+
}
6769
parent::tearDown();
6870
}
6971

0 commit comments

Comments
 (0)