From ebe10b737b45ecf678f817dfae8d93972e3f6bbb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20Sch=C3=BCttler?= Date: Tue, 8 Jan 2019 13:38:07 +0100 Subject: [PATCH] Add unit test for utf8mb4 unicode character --- .../phpunit/CRM/Utils/Mail/EmailProcessorTest.php | 13 +++++++++++++ .../Mail/data/bounces/test_utf8mb4_character.txt | 15 +++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/phpunit/CRM/Utils/Mail/data/bounces/test_utf8mb4_character.txt diff --git a/tests/phpunit/CRM/Utils/Mail/EmailProcessorTest.php b/tests/phpunit/CRM/Utils/Mail/EmailProcessorTest.php index b8ce707988..9b1d189fff 100644 --- a/tests/phpunit/CRM/Utils/Mail/EmailProcessorTest.php +++ b/tests/phpunit/CRM/Utils/Mail/EmailProcessorTest.php @@ -67,6 +67,19 @@ class CRM_Utils_Mail_EmailProcessorTest extends CiviUnitTestCase { $this->checkMailingBounces(1); } + /** + * Test that the job processing function can handle incoming utf8mb4 characters. + */ + public function testBounceProcessingUTF8mb4() { + $this->setUpMailing(); + $mail = 'test_utf8mb4_character.txt'; + + copy(__DIR__ . '/data/bounces/' . $mail, __DIR__ . '/data/mail/' . $mail); + $this->callAPISuccess('job', 'fetch_bounces', array()); + $this->assertFalse(file_exists(__DIR__ . '/data/mail/' . $mail)); + $this->checkMailingBounces(1); + } + /** * Tests that a multipart related email does not cause pain & misery & fatal errors. * diff --git a/tests/phpunit/CRM/Utils/Mail/data/bounces/test_utf8mb4_character.txt b/tests/phpunit/CRM/Utils/Mail/data/bounces/test_utf8mb4_character.txt new file mode 100644 index 0000000000..938669939d --- /dev/null +++ b/tests/phpunit/CRM/Utils/Mail/data/bounces/test_utf8mb4_character.txt @@ -0,0 +1,15 @@ +Delivered-To: my@example.com +Received: by 10.2.13.84 with SMTP id 1234567890; + Wed, 19 Dec 2018 10:01:11 +0100 (CET) +Return-Path: <> +From: my@example.com +To: b.2.1.aaaaaaaaaaaaaaaa@example.com +Subject: Vacation +Message-ID: +Date: Wed, 19 Dec 2018 10:01:07 +0100 +MIME-Version: 1.0 +Auto-Submitted: auto-replied (vacation) +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: base64 + +SSBhbSBvbiB2YWNhdGlvbiDwn4y0 \ No newline at end of file -- 2.25.1