From 433a95080e0dff709db6849a60add0a98ef96ab7 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Thu, 6 Feb 2020 15:21:59 +1100 Subject: [PATCH] [NFC] Skip utf8mb4 test on MySQL versions lower than 5.7 --- tests/phpunit/api/v3/SystemTest.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tests/phpunit/api/v3/SystemTest.php b/tests/phpunit/api/v3/SystemTest.php index ba6e77407fc1..7aef4b55af8b 100644 --- a/tests/phpunit/api/v3/SystemTest.php +++ b/tests/phpunit/api/v3/SystemTest.php @@ -87,15 +87,20 @@ public function testSystemGet() { * @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'); + } } }