You are here

public function FieldFormatterTest::testFieldFormatter in No Non-breaking Space Filter 7

Field formatter.

File

./no_nbsp.test, line 239
Tests for the no_nbsp.module.

Class

FieldFormatterTest
The no non-breaking space filter acts as a field formatter.

Code

public function testFieldFormatter() {
  $this
    ->createTextFormatWeb('with_no_nbsp', TRUE);
  $this
    ->createTextFormatWeb('without_no_nbsp', FALSE);

  // Check admin interface.
  $this
    ->drupalGet('admin/structure/types/manage/page/display');
  $this
    ->assertText(t('No Non-breaking Space Filter'));

  // Create node with full html support.
  $edit = array();
  $title = $this
    ->randomName();
  $edit['title'] = $title;
  $edit['body[und][0][value]'] = 'l   o   l';
  $edit['body[und][0][format]'] = 'without_no_nbsp';
  $this
    ->drupalPost('node/add/page', $edit, t('Save'));
  $node = $this
    ->drupalGetNodeByTitle($title);

  // The field formatter is not set.
  $this
    ->assertRaw('l   o   l');

  // Change display.
  $edit = array(
    'fields[body][type]' => 'no_nbsp',
  );
  $this
    ->drupalPost('admin/structure/types/manage/page/display', $edit, t('Save'));

  // Check if the field formatter works.
  $this
    ->drupalGet('node/' . $node->nid);
  $this
    ->assertRaw('l o l');
}