Skip to content

Commit 4fc4043

Browse files
authored
Fix failing mysql tests (cakephp#2108)
1 parent 9a6ce1e commit 4fc4043

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tests/Phinx/Db/Adapter/MysqlAdapterTest.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ protected function tearDown(): void
4242
unset($this->adapter);
4343
}
4444

45-
private function usingMysql8(): bool
45+
private function usingMysql8($adapter = null): bool
4646
{
47-
return version_compare($this->adapter->getAttribute(\PDO::ATTR_SERVER_VERSION), '8.0.0', '>=');
47+
return version_compare(($adapter ?? $this->adapter)->getAttribute(\PDO::ATTR_SERVER_VERSION), '8.0.0', '>=');
4848
}
4949

5050
public function testConnection()
@@ -408,7 +408,8 @@ public function testCreateTableAndInheritDefaultCollation()
408408
->save();
409409
$this->assertTrue($adapter->hasTable('table_with_default_collation'));
410410
$row = $adapter->fetchRow(sprintf("SHOW TABLE STATUS WHERE Name = '%s'", 'table_with_default_collation'));
411-
$this->assertEquals('utf8_unicode_ci', $row['Collation']);
411+
$collation = $this->usingMysql8($adapter) ? 'utf8mb3' : 'utf8';
412+
$this->assertEquals($collation . '_unicode_ci', $row['Collation']);
412413
}
413414

414415
public function testCreateTableWithLatin1Collate()
@@ -771,7 +772,8 @@ public function testAddStringColumnWithCustomCollation()
771772
$table->addColumn('string_collation_default', 'string', [])->save();
772773
$table->addColumn('string_collation_custom', 'string', ['collation' => 'utf8mb4_unicode_ci'])->save();
773774
$rows = $this->adapter->fetchAll('SHOW FULL COLUMNS FROM table_custom_collation');
774-
$this->assertEquals('utf8_general_ci', $rows[1]['Collation']);
775+
$collation = $this->usingMysql8() ? 'utf8mb3' : 'utf8';
776+
$this->assertEquals($collation . '_general_ci', $rows[1]['Collation']);
775777
$this->assertEquals('utf8mb4_unicode_ci', $rows[2]['Collation']);
776778
}
777779

0 commit comments

Comments
 (0)