Skip to content

Commit

Permalink
Move the default collation to a function. Fixes remaining failures wi…
Browse files Browse the repository at this point in the history
…th mariadb
  • Loading branch information
nicosp committed Dec 11, 2024
1 parent f914892 commit 117af69
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions tests/TestCase/Db/Adapter/MysqlAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ protected function tearDown(): void
unset($this->adapter, $this->out, $this->io);
}

private function getDefaultCollation(): string
{
return $this->usingMariaDbWithUuid() ?
'utf8mb4_general_ci' :
'utf8mb4_0900_ai_ci';
}

private function usingMysql8(): bool
{
$version = $this->adapter->getConnection()->getDriver()->version();
Expand Down Expand Up @@ -427,7 +434,7 @@ public function testCreateTableAndInheritDefaultCollation()
->save();
$this->assertTrue($adapter->hasTable('table_with_default_collation'));
$row = $adapter->fetchRow(sprintf("SHOW TABLE STATUS WHERE Name = '%s'", 'table_with_default_collation'));
$this->assertContains($row['Collation'], ['utf8mb4_0900_ai_ci', 'utf8mb4_unicode_520_ci']);
$this->assertEquals($row['Collation'], $this->getDefaultCollation());
}

public function testCreateTableWithLatin1Collate()
Expand Down Expand Up @@ -2182,11 +2189,7 @@ public function testDumpCreateTable()
->addColumn('column3', 'string', ['default' => 'test', 'null' => false])
->save();

if ($this->usingMariaDbWithUuid()) {
$collation = 'utf8mb4_unicode_520_ci';
} else {
$collation = 'utf8mb4_0900_ai_ci';
}
$collation = $this->getDefaultCollation();

$expectedOutput = <<<OUTPUT
CREATE TABLE `table1` (`id` INT(11) unsigned NOT NULL AUTO_INCREMENT, `column1` VARCHAR(255) NOT NULL, `column2` INT(11) NULL, `column3` VARCHAR(255) NOT NULL DEFAULT 'test', PRIMARY KEY (`id`)) ENGINE = InnoDB CHARACTER SET utf8mb4 COLLATE {$collation};
Expand Down Expand Up @@ -2293,11 +2296,7 @@ public function testDumpCreateTableAndThenInsert()
'column2' => 1,
])->save();

if ($this->usingMariaDbWithUuid()) {
$collation = 'utf8mb4_unicode_520_ci';
} else {
$collation = 'utf8mb4_0900_ai_ci';
}
$collation = $this->getDefaultCollation();

$expectedOutput = <<<OUTPUT
CREATE TABLE `table1` (`column1` VARCHAR(255) NOT NULL, `column2` INT(11) NULL, PRIMARY KEY (`column1`)) ENGINE = InnoDB CHARACTER SET utf8mb4 COLLATE {$collation};
Expand Down

0 comments on commit 117af69

Please sign in to comment.