You are here

protected function AssertMailTrait::getMails in Drupal 8

Same name and namespace in other branches
  1. 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.

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.

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