Drupal

SimpleTest 6.x gets e-mail capture!

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.


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']);
  }
}

Similar posts

Get notified on new marketing insights

Be the first to know about new B2B SaaS Marketing insights to build or refine your marketing function with the tools and knowledge of today’s industry.