From e99e79850cf01220caa897539eb3ecf79d9ef5be Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Tue, 1 Dec 2020 10:23:26 +1100 Subject: [PATCH] [NFC] Add in an Emoji test for APIv3 as per Eileen's PR --- tests/phpunit/api/v3/ContactTest.php | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/phpunit/api/v3/ContactTest.php b/tests/phpunit/api/v3/ContactTest.php index df25b45c00..5178b75a94 100644 --- a/tests/phpunit/api/v3/ContactTest.php +++ b/tests/phpunit/api/v3/ContactTest.php @@ -4936,4 +4936,34 @@ class api_v3_ContactTest extends CiviUnitTestCase { return $this->callAPISuccessGetSingle('Contact', ['id' => $isReverse ? $this->ids['contact'][1] : $this->ids['contact'][0]]); } + /** + * Test a lack of fatal errors when the where contains an emoji. + * + * By default our DBs are not 🦉 compliant. This test will age + * out when we are. + * + * @throws \API_Exception + */ + public function testEmojiInWhereClause(): void { + $schemaNeedsAlter = \CRM_Core_BAO_SchemaHandler::databaseSupportsUTF8MB4(); + if ($schemaNeedsAlter) { + \CRM_Core_DAO::executeQuery(" + ALTER TABLE civicrm_contact MODIFY COLUMN + `first_name` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'First Name.', + CHARSET utf8 + "); + } + $this->callAPISuccess('Contact', 'get', [ + 'debug' => 1, + 'first_name' => '🦉Claire', + ]); + if ($schemaNeedsAlter) { + \CRM_Core_DAO::executeQuery(" + ALTER TABLE civicrm_contact MODIFY COLUMN + `first_name` VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'First Name.', + CHARSET utf8mb4 + "); + } + } + } -- 2.25.1