From: Seamus Lee Date: Mon, 30 Nov 2020 23:23:26 +0000 (+1100) Subject: [NFC] Add in an Emoji test for APIv3 as per Eileen's PR X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e99e79850cf01220caa897539eb3ecf79d9ef5be;p=civicrm-core.git [NFC] Add in an Emoji test for APIv3 as per Eileen's PR --- 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 + "); + } + } + }