You are here

function UbercartTestHelper::findMail in Ubercart 6.2

Same name and namespace in other branches
  1. 7.3 uc_store/tests/uc_store.test \UbercartTestHelper::findMail()

Assert that an email was sent with a specific subject line.

Parameters

$pattern: A regular expression to match the subject against.

Return value

An array containing the most recently sent matching email, or FALSE if the subject line did not match anything.

1 call to UbercartTestHelper::findMail()
UbercartRolesTestCase::testRolePurchaseCheckout in uc_roles/uc_roles.test

File

uc_store/uc_store.test, line 170
Test functionality provided by uc_store.

Class

UbercartTestHelper
Defines a base helper class for Ubercart tests.

Code

function findMail($pattern) {
  foreach (array_reverse($this
    ->drupalGetMails()) as $mail) {
    if (preg_match($pattern, $mail['subject'])) {
      $this
        ->pass(t('E-mail found with subject matching %pattern.', array(
        '%pattern' => $pattern,
      )));
      return $mail;
    }
  }
  $this
    ->fail(t('E-mail not found with subject matching %pattern.', array(
    '%pattern' => $pattern,
  )));
  return FALSE;
}