function PrivatemsgLinksTestCase::testAuthorLinks in Privatemsg 6.2
Same name and namespace in other branches
- 7.2 privatemsg.test \PrivatemsgLinksTestCase::testAuthorLinks()
- 7 privatemsg.test \PrivatemsgLinksTestCase::testAuthorLinks()
Tests author links displayed on nodes and comments.
File
- ./
privatemsg.test, line 793 - Test file for privatemsg.module
Class
- PrivatemsgLinksTestCase
- Tests for node, blocks and profile integration.
Code
function testAuthorLinks() {
$admin = $this
->drupalCreateUser(array(
'read privatemsg',
'write privatemsg',
'administer privatemsg settings',
'create story content',
'create page content',
));
$user = $this
->drupalCreateUser(array(
'read privatemsg',
'write privatemsg',
'access user profiles',
));
$this
->drupalLogin($admin);
$settings = array(
'privatemsg_display_link_self' => FALSE,
'privatemsg_link_node_types[story]' => TRUE,
'privatemsg_display_on_teaser' => FALSE,
'privatemsg_display_on_comments' => TRUE,
);
$this
->drupalPost('admin/settings/messages', $settings, t('Save configuration'));
$node1 = array(
'title' => $this
->randomName(10),
'body' => $this
->randomString(50),
);
$this
->drupalPost('node/add/story', $node1, t('Save'));
$this
->clickLink(t('Add new comment'));
$comment = array(
'comment' => $this
->randomName(20),
);
// First preview, then save.
$this
->drupalPost(NULL, $comment, t('Preview'));
$this
->drupalPost(NULL, $comment, t('Save'));
$node2 = array(
'title' => $this
->randomName(),
'body' => $this
->randomString(50),
);
$this
->drupalPost('node/add/page', $node2, t('Save'));
$this
->drupalGet('node');
$this
->assertNoText(t('Send author a message'), t('Send author a message link not displayed.'));
$this
->clickLink($node1['title']);
$this
->assertNoText(t('Send author a message'), t('Send author a message link not displayed.'));
$this
->drupalLogin($user);
$this
->drupalGet('node');
$this
->assertNoText(t('Send author a message'), t('Send author a message link not displayed.'));
$this
->clickLink($node1['title']);
$this
->assertText(t('Send author a message'), t('Send author a message link displayed.'));
$this
->assertText(t('Send private message'), t('Send private message link on comment displayed.'));
$this
->clickLink(t('Send author a message'));
// To field and subject should be correctly pre-filled now.
$this
->drupalPost(NULL, array(), t('Send message'));
// Make sure the message was sent to the correct user.
$this
->assertText(t('A message has been sent to @user', array(
'@user' => $admin->name,
)));
// @todo: Do not guess nid.
$this
->drupalGet('node/2');
$this
->assertNoText(t('Send author a message'), t('Send author a message link not displayed.'));
$this
->drupalLogin($admin);
$this
->drupalGet('messages');
$this
->assertText(t('Message regarding @node', array(
'@node' => $node1['title'],
)));
}