You are here

public function CustomFormattersGeneralTestCase::testCustomFormattersEngineFormatterPreset in Custom Formatters 7.2

Test the Formatter preset Engine.

File

tests/custom_formatters.general.test, line 76
Tests for the Custom Fomratters module.

Class

CustomFormattersGeneralTestCase
Class FileFieldPathsGeneralTestCase.

Code

public function testCustomFormattersEngineFormatterPreset() {

  // Create a Custom formatter.
  $this->formatter = $this
    ->createCustomFormatter(array(
    'mode' => 'formatter_preset',
    'code' => serialize(array(
      'formatter' => 'text_trimmed',
      'settings' => array(
        'trim_length' => 10,
      ),
    )),
  ));

  // Set the formatter active on the Body field.
  $this
    ->setCustomFormatter($this->formatter->name, 'body', 'article');

  // Ensure Formatter rendered correctly.
  $this
    ->drupalGet("node/{$this->node->nid}");

  // We substring to a length of 7 characters instead of 10 characters as the
  // formatter will include the starting HTML paragraph tag in the character
  // count.
  $this
    ->assert(!strstr($this->content, $this->node->body[LANGUAGE_NONE][0]['value']) && strstr($this->content, substr($this->node->body[LANGUAGE_NONE][0]['value'], 0, 7)), t('Custom formatter output found.'));
}