You are here

function PrivatemsgFieldsTestCase::testEmptyImage in Privatemsg 7

Same name and namespace in other branches
  1. 7.2 privatemsg.test \PrivatemsgFieldsTestCase::testEmptyImage()

Verify that a message with an empty image can be sent.

File

./privatemsg.test, line 991
Test file for privatemsg.module

Class

PrivatemsgFieldsTestCase
Tests for fields integration.

Code

function testEmptyImage() {
  $admin = $this
    ->drupalCreateUser(array(
    'administer privatemsg settings',
    'write privatemsg',
    'read privatemsg',
  ));
  $user = $this
    ->drupalCreateUser(array(
    'write privatemsg',
    'read privatemsg',
  ));
  $this
    ->drupalLogin($admin);

  // Create a new field.
  $edit = array(
    'fields[_add_new_field][label]' => $label = $this
      ->randomName(),
    'fields[_add_new_field][field_name]' => $name = strtolower($this
      ->randomName()),
    'fields[_add_new_field][type]' => 'image',
    'fields[_add_new_field][widget_type]' => 'image_image',
  );
  $this
    ->drupalPost('admin/config/messaging/privatemsg/fields', $edit, t('Save'));
  $this
    ->drupalPost(NULL, array(), t('Save field settings'));
  $this
    ->drupalPost(NULL, array(), t('Save settings'));

  // Enable preview button.
  variable_set('privatemsg_display_preview_button', TRUE);

  // Preview message.
  $message = array(
    'recipient' => $user->name,
    'subject' => $this
      ->randomName(),
    'body[value]' => $this
      ->randomName(50),
  );
  $this
    ->drupalPost('messages/new', $message, t('Preview message'));

  // Send message.
  $this
    ->drupalPost(NULL, array(), t('Send message'));

  // Check message.
  $this
    ->drupalLogin($user);
  $this
    ->drupalGet('messages');
  $this
    ->clickLink($message['subject']);
  $this
    ->assertText($message['body[value]'], t('Message body displayed.'));
}