public function MassContactTest::testHtmlSupported in Mass Contact 8
Tests html support detection.
@covers ::htmlSupported
File
- tests/src/ Unit/ MassContactTest.php, line 29 
Class
- MassContactTest
- Unit tests for the Mass Contact helper service.
Namespace
Drupal\Tests\mass_contact\UnitCode
public function testHtmlSupported() {
  // Test for no modules supporting html email.
  $module_handler = $this
    ->prophesize(ModuleHandlerInterface::class);
  $module_handler
    ->moduleExists('mimemail')
    ->willReturn(FALSE);
  $module_handler
    ->moduleExists('swiftmailer')
    ->willReturn(FALSE);
  $config_factory = $this
    ->prophesize(ConfigFactoryInterface::class)
    ->reveal();
  $queue_factory = $this
    ->prophesize(QueueFactory::class)
    ->reveal();
  $mail_manager = $this
    ->prophesize(MailManagerInterface::class)
    ->reveal();
  $entity_type_manager = $this
    ->prophesize(EntityTypeManagerInterface::class)
    ->reveal();
  $opt_out = $this
    ->prophesize(OptOutInterface::class)
    ->reveal();
  $account = $this
    ->prophesize(AccountInterface::class)
    ->reveal();
  $fixture = new MassContact($module_handler
    ->reveal(), $config_factory, $queue_factory, $mail_manager, $entity_type_manager, $opt_out, $account);
  $this
    ->assertFalse($fixture
    ->htmlSupported());
  // Mime mail module.
  $module_handler
    ->moduleExists('mimemail')
    ->willReturn(TRUE);
  $fixture = new MassContact($module_handler
    ->reveal(), $config_factory, $queue_factory, $mail_manager, $entity_type_manager, $opt_out, $account);
  $this
    ->assertTrue($fixture
    ->htmlSupported());
  // Swiftmailer module.
  $module_handler
    ->moduleExists('mimemail')
    ->willReturn(FALSE);
  $module_handler
    ->moduleExists('swiftmailer')
    ->willReturn(TRUE);
  $fixture = new MassContact($module_handler
    ->reveal(), $config_factory, $queue_factory, $mail_manager, $entity_type_manager, $opt_out, $account);
  $this
    ->assertTrue($fixture
    ->htmlSupported());
}