[NFC] Skip utf8mb4 test on MySQL versions lower than 5.7
authorSeamus Lee <seamuslee001@gmail.com>
Thu, 6 Feb 2020 04:21:59 +0000 (15:21 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Thu, 6 Feb 2020 06:53:19 +0000 (17:53 +1100)
tests/phpunit/api/v3/SystemTest.php

index ba6e77407fc1b8722d3cf4e047051ba209907f66..7aef4b55af8bceade083bde78b845a287235eda0 100644 (file)
@@ -87,15 +87,20 @@ class api_v3_SystemTest extends CiviUnitTestCase {
    * @throws \CRM_Core_Exception
    */
   public function testSystemUTFMB8Conversion() {
-    $this->callAPISuccess('System', 'utf8conversion', []);
-    $table = CRM_Core_DAO::executeQuery('SHOW CREATE TABLE civicrm_contact');
-    $table->fetch();
-    $this->assertStringEndsWith('DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC', $table->Create_Table);
+    if (version_compare(CRM_Utils_SQL::getDatabaseVersion(), '5.7', '>=')) {
+      $this->callAPISuccess('System', 'utf8conversion', []);
+      $table = CRM_Core_DAO::executeQuery('SHOW CREATE TABLE civicrm_contact');
+      $table->fetch();
+      $this->assertStringEndsWith('DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC', $table->Create_Table);
 
-    $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);
+      $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);
+    }
+    else {
+      $this->markTestSkipped('MySQL Version does not support ut8mb4 testing');
+    }
   }
 
 }