Skip to content

Commit

Permalink
Fix failing mysql tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterOdin committed Oct 3, 2022
1 parent 9a6ce1e commit d2abd1b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/Phinx/Db/Adapter/MysqlAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ protected function tearDown(): void
unset($this->adapter);
}

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

public function testConnection()
Expand Down Expand Up @@ -408,7 +408,8 @@ 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->assertEquals('utf8_unicode_ci', $row['Collation']);
$collation = $this->usingMysql8() ? 'utf8mb3' : 'utf8';
$this->assertEquals($collation . '_unicode_ci', $row['Collation']);
}

public function testCreateTableWithLatin1Collate()
Expand Down Expand Up @@ -771,7 +772,8 @@ public function testAddStringColumnWithCustomCollation()
$table->addColumn('string_collation_default', 'string', [])->save();
$table->addColumn('string_collation_custom', 'string', ['collation' => 'utf8mb4_unicode_ci'])->save();
$rows = $this->adapter->fetchAll('SHOW FULL COLUMNS FROM table_custom_collation');
$this->assertEquals('utf8_general_ci', $rows[1]['Collation']);
$collation = $this->usingMysql8() ? 'utf8mb3' : 'utf8';
$this->assertEquals($collation . '_general_ci', $rows[1]['Collation']);
$this->assertEquals('utf8mb4_unicode_ci', $rows[2]['Collation']);
}

Expand Down

0 comments on commit d2abd1b

Please sign in to comment.