protected function AssertMailTrait::assertMail in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Test/AssertMailTrait.php \Drupal\Core\Test\AssertMailTrait::assertMail()
- 9 core/lib/Drupal/Core/Test/AssertMailTrait.php \Drupal\Core\Test\AssertMailTrait::assertMail()
Asserts that the most recently sent email message has the given value.
The field in $name must have the content described in $value.
Parameters
string $name: Name of field or message property to assert. Examples: subject, body, id, ...
string $value: Value of the field to assert.
string $message: (optional) A message to display with the assertion. Do not translate messages: use \Drupal\Component\Render\FormattableMarkup to embed variables in the message text, not t(). If left blank, a default message will be displayed.
string $group: (optional) The group this message is in, which is displayed in a column in test output. Use 'Debug' to indicate this is debugging output. Do not translate this string. Defaults to 'Email'; most tests do not override this default.
Return value
bool TRUE on pass.
2 calls to AssertMailTrait::assertMail()
- AssertMailTraitTest::testAssertMailTrait in core/
tests/ Drupal/ KernelTests/ Core/ Test/ AssertMailTraitTest.php - Tests that the maintenance theme initializes the theme and its base themes.
- MailCaptureTest::testMailSend in core/
tests/ Drupal/ FunctionalTests/ MailCaptureTest.php - Tests to see if the wrapper function is executed correctly.
File
- core/
lib/ Drupal/ Core/ Test/ AssertMailTrait.php, line 62
Class
- AssertMailTrait
- Provides methods for testing emails sent during test runs.
Namespace
Drupal\Core\TestCode
protected function assertMail($name, $value = '', $message = '', $group = 'Email') {
$captured_emails = $this->container
->get('state')
->get('system.test_mail_collector') ?: [];
$email = end($captured_emails);
$this
->assertIsArray($email, $message);
$this
->assertArrayHasKey($name, $email, $message);
$this
->assertEquals($value, $email[$name], $message);
return TRUE;
}