You are here

function MessageShowMessage::testPartials in Message 7

Test getting only a single delta from the field.

File

tests/message.test, line 158

Class

MessageShowMessage
Test the Message CRUD handling.

Code

function testPartials() {
  $text1 = $this
    ->randomName();
  $text2 = $this
    ->randomName();
  $message_type = message_type_create('foo');
  $message_type->{MESSAGE_FIELD_MESSAGE_TEXT} = array(
    LANGUAGE_NONE => array(
      0 => array(
        'value' => $text1,
        'format' => 'plain_text',
      ),
      1 => array(
        'value' => $text2,
        'format' => 'filtered_html',
      ),
    ),
  );
  $message_type
    ->save();
  $message = message_create('foo');
  $this
    ->assertEqual($text1 . "\n" . $text2 . "\n", strip_tags($message
    ->getText()), t('Got correct text for all deltas.'));
  $options = array(
    'partials' => TRUE,
    'partial delta' => 0,
  );
  $this
    ->assertEqual($text1 . "\n", strip_tags($message
    ->getText(LANGUAGE_NONE, $options)), t('Got correct text for the 1st delta.'));
  $options['partial delta'] = 1;
  $this
    ->assertEqual($text2 . "\n", strip_tags($message
    ->getText(LANGUAGE_NONE, $options)), t('Got correct text for the 2nd delta.'));
}