class MassContactTest in Mass Contact 8
Same name in this branch
- 8 tests/src/Unit/MassContactTest.php \Drupal\Tests\mass_contact\Unit\MassContactTest
- 8 tests/src/Kernel/MassContactTest.php \Drupal\Tests\mass_contact\Kernel\MassContactTest
Unit tests for the Mass Contact helper service.
@group mass_contact
@coversDefaultClass \Drupal\mass_contact\MassContact
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\mass_contact\Unit\MassContactTest
Expanded class hierarchy of MassContactTest
File
- tests/
src/ Unit/ MassContactTest.php, line 22
Namespace
Drupal\Tests\mass_contact\UnitView source
class MassContactTest extends UnitTestCase {
/**
* Tests html support detection.
*
* @covers ::htmlSupported
*/
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());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MassContactTest:: |
public | function | Tests html support detection. | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. | |
UnitTestCase:: |
protected | function | 340 |