SimpleTest 6.x gets e-mail capture!

dylan

One email was captured.
The latest 6.x-2.9 release of SimpleTest includes a backport of the e-mail capture feature from D7. This means you can finally unit test e-mail sending functionality! There is still one bug to be ironed out, but a patch is available.

Here's a simple demo of how it works:

class UserTestCase extends DrupalWebTestCase {
  public static function getInfo() {
    return array(
      'name' => t('User functionality'),
      'description' => t('Test user creation.'),
      'group' => t('User'),
    );
  }
 
  /**
   * Test receiving user welcome e-mail.
   */
  function testUserWelcome() {
    $name = $this->randomName();
    $edit = array(
      'name' => $name,
      'mail' => "$name@example.com",
    );
    $this->drupalPost('user/register', $edit, t('Create new account'));
    $this->assertMail('to', $edit['mail']);
  }
}

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><blockquote>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. Beside the tag style "<foo>" it is also possible to use "[foo]".

More information about formatting options