public function Anonymouspublishingtest::createByPeBoth in Anonymous Publishing 7
Self-activate, persistent validation(0), by(2).
1 call to Anonymouspublishingtest::createByPeBoth()
- Anonymouspublishingtest::testAnonymouspublishing in tests/
anonymous_publishing.test - The main test function.
File
- tests/
anonymous_publishing.test, line 275
Class
- Anonymouspublishingtest
- Tests for the Anonymous Publishing modules.
Code
public function createByPeBoth($type) {
debug('Tests: E.1, E.2, E.3, E.4, E.5, E.6, E.7, E.8');
variable_set('anonymous_publishing_cl_vrfypers', 0);
variable_set('anonymous_publishing_cl_alias', 2);
$email = 'blogger4@example.com';
$this
->createNode('blog', $email, 'John Bull');
$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('Submitted by John Bull', 'Node by John Bull published.');
$this
->drupalGet($url, $options);
$this
->assertText('Stale activation key', 'Error: Stale activation key.');
$this
->createNode('blog', 'blogger4@example.com', 'Sitting Bull');
$this
->assertText('Submitted by Sitting Bull', 'Node by returning contributor Sitting Bull posted.');
$urlnode = substr($url, 0, strpos($url, '/verify'));
$email = 'commenter4@example.com';
$this
->createComment($urlnode, $email, 'John Bull');
$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('your comment has been published', 'Comment by John Bull published.');
$this
->drupalGet($url, $options);
$this
->assertText('Stale activation key', 'Error: Stale activation key.');
$this
->createComment($urlnode, 'commenter4@example.com', 'Crazy Horse');
$this
->assertText('Your comment has been posted.', 'Comment by returning contributor Crazy Horse posted.');
}