Add unit test for utf8mb4 unicode character
authorThomas Schüttler <tschuettler@oxfam.de>
Tue, 8 Jan 2019 12:38:07 +0000 (13:38 +0100)
committerThomas Schüttler <tschuettler@oxfam.de>
Tue, 8 Jan 2019 12:38:07 +0000 (13:38 +0100)
tests/phpunit/CRM/Utils/Mail/EmailProcessorTest.php
tests/phpunit/CRM/Utils/Mail/data/bounces/test_utf8mb4_character.txt [new file with mode: 0644]

index b8ce70798876db646a4a05136441b29b567ef76e..9b1d189fffa741c1c47ec8388989f8db7b1afbf6 100644 (file)
@@ -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 (file)
index 0000000..9386699
--- /dev/null
@@ -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: <abc.def.fhi@example.com>
+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