Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Test/AssertMailTrait.php \Drupal\Core\Test\AssertMailTrait::getMails()
  2. 9 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.

21 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::testPersonalContactForm in core/modules/contact/tests/src/Functional/ContactPersonalTest.php
Tests that the opt-out message is included correctly in contact emails.

... See full list

File

core/lib/Drupal/Core/Test/AssertMailTrait.php, line 22

Class

AssertMailTrait
Provides methods for testing emails sent during test runs.

Namespace

Drupal\Core\Test

Code

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;
}