You are here

public function Anonymouspublishingtest::createUnPeBoth in Anonymous Publishing 7

Self-activate.

Make verification persistent. Use an autogenerated persistent alias (format “userN”).

1 call to Anonymouspublishingtest::createUnPeBoth()
Anonymouspublishingtest::testAnonymouspublishing in tests/anonymous_publishing.test
The main test function.

File

tests/anonymous_publishing.test, line 231

Class

Anonymouspublishingtest
Tests for the Anonymous Publishing modules.

Code

public function createUnPeBoth($type) {
  variable_set('anonymous_publishing_cl_vrfypers', 0);
  variable_set('anonymous_publishing_cl_alias', 1);
  $email = 'blogger3@example.com';
  $this
    ->createNode('blog', $email);
  $this
    ->assertText('You must also confirm that ' . $email . ' belongs to you.', 'D.1: Node created');
  $mails = $this
    ->drupalGetMails();
  $lastmail = count($mails) - 1;
  $url = substr($mails[$lastmail]['body'], strpos($mails[$lastmail]['body'], 'http'));
  $url = substr($url, 0, strpos($url, '/verify') + 7);
  $path = substr($mails[$lastmail]['body'], strpos($mails[$lastmail]['body'], 'akey=') + 5);
  $path = substr($path, 0, strpos($path, '.'));
  $options['query'] = array(
    'akey' => $path,
  );
  $this
    ->drupalGet($url, $options);
  $this
    ->assertText('Thanks for verifying your e-mail', 'D.2: Node by published.');
  $this
    ->assertText('Submitted by user', 'D.3: Persistent alias as byline.');
  $this
    ->drupalGet($url, $options);
  $this
    ->assertText('Stale activation key', 'D.4: Error: Stale activation key.');
  $this
    ->createNode('blog', 'blogger3@example.com');
  $this
    ->assertText('Your email has been activated previously', 'D.5: Node by returning contributor posted.');
  $this
    ->assertText('Submitted by user', 'D.6: Persistent alias as byline.');
  $urlnode = substr($url, 0, strpos($url, '/verify'));
  $email = 'commenter3@example.com';
  $this
    ->createComment($urlnode, $email);
  $this
    ->assertText('You must also confirm that ' . $email . ' belongs to you.', 'D.7: Comment created');
  $mails = $this
    ->drupalGetMails();
  $lastmail = count($mails) - 1;
  $url = substr($mails[$lastmail]['body'], strpos($mails[$lastmail]['body'], 'http'));
  $url = substr($url, 0, strpos($url, '/verify') + 7);
  $path = substr($mails[$lastmail]['body'], strpos($mails[$lastmail]['body'], 'akey=') + 5);
  $path = substr($path, 0, strpos($path, '.'));
  $options['query'] = array(
    'akey' => $path,
  );
  $this
    ->drupalGet($url, $options);
  $this
    ->assertText('your comment has been published', 'D.8: Comment published.');
  $this
    ->drupalGet($url, $options);
  $this
    ->assertText('Stale activation key', 'D.9: Error: Stale activation key.');
  $this
    ->createComment($urlnode, 'commenter3@example.com');
  $this
    ->assertText('Your comment has been posted.', 'D.10: Comment by returning contributor posted.');
  $this
    ->assertText('Submitted by user', 'D.11: Persistent alias as byline.');
}