You are here

class SwiftMailerTest in Swift Mailer 8

Same name in this branch
  1. 8 tests/src/Unit/Plugin/Mail/SwiftMailerTest.php \Drupal\Tests\swiftmailer\Unit\Plugin\Mail\SwiftMailerTest
  2. 8 tests/src/Kernel/Plugin/Mail/SwiftMailerTest.php \Drupal\Tests\swiftmailer\Kernel\Plugin\Mail\SwiftMailerTest

@coversDefaultClass \Drupal\swiftmailer\Plugin\Mail\SwiftMailer @group swiftmailer

Hierarchy

  • class \Drupal\Tests\swiftmailer\Unit\Plugin\Mail\SwiftMailerTest extends \PHPUnit\Framework\TestCase

Expanded class hierarchy of SwiftMailerTest

File

tests/src/Unit/Plugin/Mail/SwiftMailerTest.php, line 16

Namespace

Drupal\Tests\swiftmailer\Unit\Plugin\Mail
View source
class SwiftMailerTest extends TestCase {

  /**
   * @covers ::massageMessageBody
   */
  public function testMassageMessageBody() {
    $method = new \ReflectionMethod(SwiftMailer::class, 'massageMessageBody');
    $method
      ->setAccessible(TRUE);
    $mailer = $this
      ->getMockBuilder(SwiftMailer::class)
      ->disableOriginalConstructor()
      ->getMock();
    $body = [
      'Hello World',
      'Hello <strong>World</strong>',
      new FormattableMarkup('Hello World #@number', [
        '@number' => 2,
      ]),
      Markup::create('Hello <strong>World</strong>'),
    ];
    $result = [
      'Hello World',
      'Hello &lt;strong&gt;World&lt;/strong&gt;',
      'Hello World #2',
      'Hello <strong>World</strong>',
    ];
    $message = $method
      ->invoke($mailer, [
      'body' => $body,
    ]);
    $this
      ->assertSame(implode(PHP_EOL, $result), (string) $message['body']);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SwiftMailerTest::testMassageMessageBody public function @covers ::massageMessageBody