Skip to content

Commit fb08f7d

Browse files
committed
refactor(tests): teardown is now always called - also when skipped
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 873c119 commit fb08f7d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tests/lib/Repair/RepairCollationTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ public function getAllNonUTF8BinTables(IDBConnection $connection) {
3131
/**
3232
* Tests for the converting of MySQL tables to InnoDB engine
3333
*
34-
* @group DB
35-
*
3634
* @see \OC\Repair\RepairMimeTypes
3735
*/
36+
#[\PHPUnit\Framework\Attributes\Group('DB')]
3837
class RepairCollationTest extends TestCase {
3938

4039
private TestCollationRepair $repair;
@@ -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)