More updates to stop using dev or alpha or beta versions.
[yaffs-website] / web / core / tests / Drupal / Tests / Core / Mail / MailFormatHelperTest.php
1 <?php
2
3 namespace Drupal\Tests\Core\Mail;
4
5 use Drupal\Core\Mail\MailFormatHelper;
6 use Drupal\Tests\UnitTestCase;
7
8 /**
9  * @coversDefaultClass \Drupal\Core\Mail\MailFormatHelper
10  * @group Mail
11  */
12 class MailFormatHelperTest extends UnitTestCase {
13
14   /**
15    * @covers ::wrapMail
16    */
17   public function testWrapMail() {
18     $delimiter = "End of header\n";
19     $long_file_name = $this->randomMachineName(64) . '.docx';
20     $headers_in_body = 'Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document; name="' . $long_file_name . "\"\n";
21     $headers_in_body .= "Content-Transfer-Encoding: base64\n";
22     $headers_in_body .= 'Content-Disposition: attachment; filename="' . $long_file_name . "\"\n";
23     $headers_in_body .= 'Content-Description: ' . $this->randomMachineName(64);
24     $body = $this->randomMachineName(76) . ' ' . $this->randomMachineName(6);
25     $wrapped_text = MailFormatHelper::wrapMail($headers_in_body . $delimiter . $body);
26     list($processed_headers, $processed_body) = explode($delimiter, $wrapped_text);
27
28     // Check that the body headers were not wrapped even though some exceeded
29     // 77 characters.
30     $this->assertEquals($headers_in_body, $processed_headers, 'Headers in the body are not wrapped.');
31     // Check that the body text is wrapped.
32     $this->assertEquals(wordwrap($body, 77, " \n"), $processed_body, 'Body text is wrapped.');
33   }
34
35 }