[NFC] Update System Uft8mb4 check to handle for the fact that MySQL8 outputs utf8mb3...
authorSeamus Lee <seamuslee001@gmail.com>
Wed, 8 Dec 2021 00:14:33 +0000 (11:14 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Wed, 8 Dec 2021 00:14:33 +0000 (11:14 +1100)
tests/phpunit/api/v3/SystemTest.php

index 8eae0622a712adc83d4c537e174fddb5b79a9e3a..275dad39dc356e3fdc3f6ce3e852603ab4b576dd 100644 (file)
@@ -96,7 +96,9 @@ class api_v3_SystemTest extends CiviUnitTestCase {
       $this->callAPISuccess('System', 'utf8conversion', ['is_revert' => 1]);
       $table = CRM_Core_DAO::executeQuery('SHOW CREATE TABLE civicrm_contact');
       $table->fetch();
-      $this->assertStringEndsWith('DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC', $table->Create_Table);
+      $version = CRM_Utils_SQL::getDatabaseVersion();
+      $charset = (version_compare($version, '8', '>=') && stripos($version, 'mariadb') === FALSE) ? 'utf8mb3' : 'utf8';
+      $this->assertStringEndsWith('DEFAULT CHARSET=' . $charset . ' COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC', $table->Create_Table);
     }
     else {
       $this->markTestSkipped('MySQL Version does not support ut8mb4 testing');