function 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.
20 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.
 - AssertMailTrait::verboseEmail in core/
lib/ Drupal/ Core/ Test/ AssertMailTrait.php  - Outputs to verbose the most recent $count emails sent.
 - AssertMailTraitTest::testAssertMailTrait in core/
tests/ Drupal/ KernelTests/ Core/ Test/ AssertMailTraitTest.php  - Tests that the maintenance theme initializes the theme and its base themes.
 - ConfigTranslationUiTest::testContactConfigEntityTranslation in core/
modules/ config_translation/ tests/ src/ Functional/ ConfigTranslationUiTest.php  - Tests the contact form translation.
 
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.