You are here

public function ProtectedNodeMail::testSendMail in Protected Node 7

Same name and namespace in other branches
  1. 1.0.x tests/protected_node.mail_test.test \ProtectedNodeMail::testSendMail()

Test that a mail is send when a protected node is created.

File

tests/protected_node.mail_test.test, line 44
Test protected node email functionality.

Class

ProtectedNodeMail
Configure protected_node to send email.

Code

public function testSendMail() {

  // Log in as Admin.
  $this
    ->drupalLogin($this->adminUser);

  // Generate random password.
  $password = $this
    ->randomName(10);

  // To parameter.
  $to = 'example@example.com';

  // Create a new page node.
  $this
    ->createProtectedNode($password, $to);

  // Once the node created logout the User.
  $this
    ->drupalLogout();
  $mails = $this
    ->drupalGetMails();

  // Check mail subject.
  $this
    ->assertMail('subject', protected_node_email_subject(), 'The last message subject was "My latest email"');

  // Check mail to parameter.
  $this
    ->assertEqual($to, $mails[0]['to'], "The mail's to parameter is equal to " . $to, $this->group);
}