function AssertMailTrait::getMails
Same name in other branches
- 9 core/lib/Drupal/Core/Test/AssertMailTrait.php \Drupal\Core\Test\AssertMailTrait::getMails()
- 8.9.x core/lib/Drupal/Core/Test/AssertMailTrait.php \Drupal\Core\Test\AssertMailTrait::getMails()
- 11.x core/lib/Drupal/Core/Test/AssertMailTrait.php \Drupal\Core\Test\AssertMailTrait::getMails()
Gets an array containing all emails sent during this test case.
Parameters
array $filter: An array containing key/value pairs used to filter the emails that are returned.
Return value
array An array containing email messages captured during the current test.
22 calls to AssertMailTrait::getMails()
- AssertMailTrait::assertMailPattern in core/
lib/ Drupal/ Core/ Test/ AssertMailTrait.php - Asserts that the most recently sent email message has the pattern in it.
- AssertMailTrait::assertMailString in core/
lib/ Drupal/ Core/ Test/ AssertMailTrait.php - Asserts that the most recently sent email message has the string in it.
- AssertMailTraitTest::testAssertMailTrait in core/
tests/ Drupal/ KernelTests/ Core/ Test/ AssertMailTraitTest.php - Tests that the maintenance theme initializes the theme and its base themes.
- ConfigTranslationUiModulesTest::testContactConfigEntityTranslation in core/
modules/ config_translation/ tests/ src/ Functional/ ConfigTranslationUiModulesTest.php - Tests the contact form translation.
- ContactPersonalTest::testPersonalContactFormUserCopy in core/
modules/ contact/ tests/ src/ Functional/ ContactPersonalTest.php - Tests that the opt-out message is not included in user copy emails.
File
-
core/
lib/ Drupal/ Core/ Test/ AssertMailTrait.php, line 22
Class
- AssertMailTrait
- Provides methods for testing emails sent during test runs.
Namespace
Drupal\Core\TestCode
protected function getMails(array $filter = []) {
$captured_emails = $this->container
->get('state')
->get('system.test_mail_collector', []);
$filtered_emails = [];
foreach ($captured_emails as $message) {
foreach ($filter as $key => $value) {
if (!isset($message[$key]) || $message[$key] != $value) {
continue 2;
}
}
$filtered_emails[] = $message;
}
return $filtered_emails;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.