public function Anonymouspublishingtest::createSaPeBoth in Anonymous Publishing 7
Self-activate, persistent validation(0), NA(0)
1 call to Anonymouspublishingtest::createSaPeBoth()
- Anonymouspublishingtest::testAnonymouspublishing in tests/
anonymous_publishing.test - The main test function.
File
- tests/
anonymous_publishing.test, line 139
Class
- Anonymouspublishingtest
- Tests for the Anonymous Publishing modules.
Code
public function createSaPeBoth($type) {
variable_set('anonymous_publishing_cl_vrfypers', 0);
variable_set('anonymous_publishing_cl_alias', 0);
$this
->drupalGet('/node/add/blog');
$email = 'blogger@example.com';
$this
->createNode('blog', $email);
$this
->assertText('You must also confirm that ' . $email . ' belongs to you.', 'B.1: Node created');
$mails = $this
->drupalGetMails();
$lastmail = count($mails) - 1;
$this
->assertTrue(0 <= $lastmail, 'B.2: Got at least one mail', 'SaPeBoth');
$this
->assertEqual($mails[$lastmail]['subject'], 'Please activate your content on Drupal', 'B.2: Got activation mail [' . $lastmail . ']', 'SaPeBoth');
$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', 'B.3: Node published.');
$this
->drupalGet($url, $options);
$this
->assertText('Stale activation key', 'B.4: Error: Stale activation key.');
$this
->createNode('blog', 'blogger@example.com');
$this
->assertText('Your email has been activated previously.', 'B.5: Node by returning contributor posted.');
$urlnode = substr($url, 0, strpos($url, '/verify'));
$email = 'commenter@example.com';
$this
->createComment($urlnode, $email);
$this
->assertText('You must also confirm that ' . $email . ' belongs to you.', 'B.6: 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', 'B.7: Comment published.');
$this
->drupalGet($url, $options);
$this
->assertText('Stale activation key', 'B.8: Error: Stale activation key.');
$this
->createComment($urlnode, 'commenter@example.com');
$this
->assertText('Your email has been activated previously.', 'B.9: Comment by returning contributor posted.');
}