Skip to content

Commit debd054

Browse files
authored
Fix ci for mariadb (#1024)
* Fix ci for mariadb * Fix ci for mariadb * Added collation for MariaDB 11.8 to fix tests.
1 parent 304c597 commit debd054

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ jobs:
8080
8181
sleep 2
8282
done
83-
mariadb -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE cakephp_comparisons;'
84-
mariadb -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE cakephp_snapshot;'
83+
docker exec mariadb mariadb -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE cakephp_comparisons;'
84+
docker exec mariadb mariadb -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE cakephp_snapshot;'
8585
- name: Setup MySQL
8686
if: matrix.db-type == 'mysql'
8787
run: |

tests/TestCase/Db/Adapter/MysqlAdapterTest.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,6 @@ protected function tearDown(): void
7979
unset($this->adapter, $this->out, $this->io);
8080
}
8181

82-
private function getDefaultCollation(): string
83-
{
84-
return $this->usingMariaDbWithUuid() ?
85-
'utf8mb4_general_ci' :
86-
'utf8mb4_0900_ai_ci';
87-
}
88-
8982
private function usingMysql8(): bool
9083
{
9184
$version = $this->adapter->getConnection()->getDriver()->version();
@@ -461,7 +454,7 @@ public function testCreateTableAndInheritDefaultCollation()
461454
->save();
462455
$this->assertTrue($adapter->hasTable('table_with_default_collation'));
463456
$row = $adapter->fetchRow(sprintf("SHOW TABLE STATUS WHERE Name = '%s'", 'table_with_default_collation'));
464-
$this->assertContains($row['Collation'], ['utf8mb4_general_ci', 'utf8mb4_0900_ai_ci', 'utf8mb4_unicode_ci']);
457+
$this->assertContains($row['Collation'], ['utf8mb4_general_ci', 'utf8mb4_0900_ai_ci', 'utf8mb4_uca1400_ai_ci', 'utf8mb4_unicode_ci']);
465458
}
466459

467460
public function testCreateTableWithLatin1Collate()
@@ -2288,8 +2281,9 @@ public function testDumpCreateTable()
22882281

22892282
$actualOutput = join("\n", $this->out->messages());
22902283
// MySQL version affects default collation (8.0.0+ uses utf8mb4_0900_ai_ci, older uses utf8mb4_general_ci)
2284+
// MariaDB 11.8 uses: utf8mb4_uca1400_ai_ci
22912285
$this->assertMatchesRegularExpression(
2292-
'/CREATE TABLE `table1` \(`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, `column1` VARCHAR\(255\) NOT NULL, `column2` INTEGER, `column3` VARCHAR\(255\) NOT NULL DEFAULT \'test\', PRIMARY KEY \(`id`\)\) ENGINE = InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_(0900_ai_ci|general_ci);/',
2286+
'/CREATE TABLE `table1` \(`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, `column1` VARCHAR\(255\) NOT NULL, `column2` INTEGER, `column3` VARCHAR\(255\) NOT NULL DEFAULT \'test\', PRIMARY KEY \(`id`\)\) ENGINE = InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_(0900_ai_ci|uca1400_ai_ci|general_ci);/',
22932287
$actualOutput,
22942288
'Passing the --dry-run option does not dump create table query to the output',
22952289
);
@@ -2398,7 +2392,7 @@ public function testDumpCreateTableAndThenInsert()
23982392
$actualOutput = preg_replace('~\R~u', '', $actualOutput);
23992393
// MySQL version affects default collation (8.0.0+ uses utf8mb4_0900_ai_ci, older uses utf8mb4_general_ci)
24002394
$this->assertMatchesRegularExpression(
2401-
'/CREATE TABLE `table1` \(`column1` VARCHAR\(255\) NOT NULL, `column2` INTEGER, PRIMARY KEY \(`column1`\)\) ENGINE = InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_(0900_ai_ci|general_ci);INSERT INTO `table1` \(`column1`, `column2`\) VALUES \(\'id1\', 1\);/',
2395+
'/CREATE TABLE `table1` \(`column1` VARCHAR\(255\) NOT NULL, `column2` INTEGER, PRIMARY KEY \(`column1`\)\) ENGINE = InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_(0900_ai_ci|uca1400_ai_ci|general_ci);INSERT INTO `table1` \(`column1`, `column2`\) VALUES \(\'id1\', 1\);/',
24022396
$actualOutput,
24032397
'Passing the --dry-run option does not dump create and then insert table queries to the output',
24042398
);

0 commit comments

Comments
 (0)