function PrivatemsgTestCase::testPreview in Privatemsg 7.2
Same name and namespace in other branches
- 6.2 privatemsg.test \PrivatemsgTestCase::testPreview()
- 6 privatemsg.test \PrivatemsgTestCase::testPreview()
- 7 privatemsg.test \PrivatemsgTestCase::testPreview()
Test preview functionality.
File
- ./
privatemsg.test, line 824 - Test file for privatemsg.module
Class
Code
function testPreview() {
$user = $this
->drupalCreateUser(array(
'read privatemsg',
'write privatemsg',
));
// Enable preview button.
variable_set('privatemsg_display_preview_button', TRUE);
$message = array(
'recipient' => $user->name,
'subject' => $this
->randomName(),
'body[value]' => $this
->randomName(50),
);
$this
->drupalLogin($user);
// Preview message.
$this
->drupalPost('messages/new', $message, t('Preview message'));
$this
->assertFieldByXPath($this
->buildXPathQuery('//div[@class=:class]/p', array(
':class' => 'privatemsg-message-body',
)), $message['body[value]'], t('Message body is previewed'));
$this
->assertFieldByName('body[value]', $message['body[value]'], t('Message body field has the correct default value.'));
// Send message.
$this
->drupalPost(NULL, array(), t('Send message'));
$this
->assertText($message['subject'], t('Message subject is displayed.'));
$this
->assertText($message['body[value]'], t('Message body is displayed.'));
$this
->assertText(t('A message has been sent to @recipient.', array(
'@recipient' => $user->name,
)), t('Sent confirmation displayed.'));
}