You are here

public function CommentNotifyAnonymousTest::testMail in Comment Notify 8

Tests that the mail is required for anonymous users.

File

tests/src/Functional/CommentNotifyAnonymousTest.php, line 36

Class

CommentNotifyAnonymousTest
Comment notifications tests as anonymous user.

Namespace

Drupal\Tests\comment_notify\Functional

Code

public function testMail() {

  /** @var \Drupal\node\Entity\Node $node */
  $node = $this
    ->drupalCreateNode([
    'type' => 'article',
  ]);
  $subscribe = [
    'notify' => TRUE,
    'notify_type' => COMMENT_NOTIFY_ENTITY,
  ];
  $this
    ->drupalGet($node
    ->toUrl());
  $this
    ->postComment($node
    ->toUrl()
    ->toString(), $this
    ->randomMachineName(), $this
    ->randomMachineName(), $subscribe);
  $this
    ->assertTrue($this
    ->getSession()
    ->getPage()
    ->hasContent(t('If you want to subscribe to comments you must supply a valid e-mail address.')));
}