You are here

public function Anonymouspublishingtest::createSaNpBoth in Anonymous Publishing 7

Self-activate, verify each post(2), NA(0).

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

File

tests/anonymous_publishing.test, line 184

Class

Anonymouspublishingtest
Tests for the Anonymous Publishing modules.

Code

public function createSaNpBoth($type) {
  debug('Tests: C.1, C.2, C.3, C.4, C.5, C.6, C.7, C.8');
  variable_set('anonymous_publishing_cl_vrfypers', 2);
  variable_set('anonymous_publishing_cl_alias', 0);
  $email = 'blogger2@example.com';
  $this
    ->createNode('blog', $email);
  $this
    ->assertText('You must also confirm that ' . $email . ' belongs to you.', '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', 'Node published.');
  $this
    ->drupalGet($url, $options);
  $this
    ->assertText('Stale activation key', 'Error: Stale activation key.');
  $email = 'blogger2@example.com';
  $this
    ->createNode('blog', $email);
  $this
    ->assertText('You must also confirm that ' . $email . ' belongs to you.', 'Node created');
  $urlnode = substr($url, 0, strpos($url, '/verify'));
  $email = 'commenter2@example.com';
  $this
    ->createComment($urlnode, $email);
  $this
    ->assertText('You must also confirm that ' . $email . ' belongs to you.', '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('Thanks for verifying', 'Comment published.');
  $this
    ->drupalGet($url, $options);
  $this
    ->assertText('Stale activation key', 'Error: Stale activation key.');
  $email = 'commenter@example.com';
  $this
    ->createComment($urlnode, $email);
  $this
    ->assertText('You must also confirm that ' . $email . ' belongs to you.', 'Node created');
}