You are here

protected function DrupalWebTestCase::assertMailPattern in SimpleTest 7.2

Same name and namespace in other branches
  1. 6.2 drupal_web_test_case.php \DrupalWebTestCase::assertMailPattern()

Asserts that the most recently sent e-mail message has the pattern in it.

Parameters

$field_name: Name of field or message property to assert: subject, body, id, ...

$regex: Pattern to search for.

Return value

TRUE on pass, FALSE on fail.

File

./drupal_web_test_case.php, line 3398
Provides DrupalTestCase, DrupalUnitTestCase, and DrupalWebTestCase classes.

Class

DrupalWebTestCase
Test case for typical Drupal tests.

Code

protected function assertMailPattern($field_name, $regex, $message) {
  $mails = $this
    ->drupalGetMails();
  $mail = end($mails);
  $regex_found = preg_match("/{$regex}/", $mail[$field_name]);
  return $this
    ->assertTrue($regex_found, t('Expected text found in @field of email message: "@expected".', array(
    '@field' => $field_name,
    '@expected' => $regex,
  )));
}