From b9f2d205e8c4868840181aff5a58a2cd1197252b Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Tue, 8 Jun 2021 12:00:53 -0400 Subject: [PATCH] unit test for db insert in TR locale --- tests/phpunit/CRM/Core/I18n/LocaleTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/phpunit/CRM/Core/I18n/LocaleTest.php b/tests/phpunit/CRM/Core/I18n/LocaleTest.php index 56215e6438..49a044444c 100644 --- a/tests/phpunit/CRM/Core/I18n/LocaleTest.php +++ b/tests/phpunit/CRM/Core/I18n/LocaleTest.php @@ -87,4 +87,23 @@ class CRM_Core_I18n_LocaleTest extends CiviUnitTestCase { Civi::$statics['CRM_Core_I18n']['singleton'] = []; } + /** + * Quirk in strtolower does not handle "I" as expected, compared to mb_strtolower. + * I think setting locale messes up something that I don't know how to reset, + * so see if these help: + * @runInSeparateProcess + * @preserveGlobalState disabled + */ + public function testInsertTurkish() { + CRM_Core_DAO::executeQuery("DROP TABLE IF EXISTS foo"); + CRM_Core_DAO::executeQuery("CREATE TABLE foo ( bar varchar(32) )"); + // Change locale - assert it actually changed. + $this->assertEquals('tr_TR.utf8', setlocale(LC_ALL, 'tr_TR.utf8')); + $dao = new CRM_Core_DAO(); + // When query() uses strtolower this returns NULL instead + $this->assertEquals(1, $dao->query("INSERT INTO foo VALUES ('Turkish Delight')")); + setlocale(LC_ALL, 'en_US'); + CRM_Core_DAO::executeQuery("DROP TABLE foo"); + } + } -- 2.25.1