You are here

public function CustomFormattersGeneralTestCase::testCustomFormattersUi in Custom Formatters 7.2

Test General UI related functionality.

File

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

Class

CustomFormattersGeneralTestCase
Class FileFieldPathsGeneralTestCase.

Code

public function testCustomFormattersUi() {
  $this
    ->drupalGet('admin/structure/formatters');

  // Ensure the Formatters overview page is present.
  $expected_title = t('!title | !sitename', array(
    '!title' => 'Formatters',
    '!sitename' => variable_get('site_name', 'Drupal'),
  ));
  $this
    ->assertTitle($expected_title);

  // Ensure the Settings link is present and correct.
  $this
    ->assertLink(t('Settings'));
  $this
    ->assertLinkByHref('admin/structure/formatters/settings');

  // Ensure our pre-prepared test formatter is present.
  $this
    ->assertText('Test Formatter');
  $this
    ->assertLinkByHref('admin/structure/formatters/list/test_formatter/edit');
  $this
    ->assertCustomFormatterExists('test_formatter');

  // Ensure our pre-prepared test formatter is present on the Manage display
  // page.
  $this
    ->drupalGet('admin/structure/types/manage/article/display');
  $this
    ->assertRaw('custom_formatters_test_formatter');
  $this
    ->assertRaw('Custom: Test Formatter');

  // Change the Label prefix.
  $edit = array(
    'settings[label_prefix_value]' => $this
      ->randomName(),
  );
  $this
    ->drupalPost('admin/structure/formatters/settings', $edit, t('Save'));
  $this
    ->assertText(t('Custom Formatters settings have been updated.'));

  // Ensure our pre-prepared test formatter is present on the Manage display
  // page with the altered label prefix.
  $this
    ->drupalGet('admin/structure/types/manage/article/display');
  $this
    ->assertRaw(t('@prefix: Test Formatter', array(
    '@prefix' => $edit['settings[label_prefix_value]'],
  )));

  // Remove the Label prefix.
  $edit = array(
    'settings[label_prefix]' => FALSE,
  );
  $this
    ->drupalPost('admin/structure/formatters/settings', $edit, t('Save'));
  $this
    ->assertText(t('Custom Formatters settings have been updated.'));

  // Ensure our pre-prepared test formatter is present on the Manage display
  // page without a label prefix.
  $this
    ->drupalGet('admin/structure/types/manage/article/display');
  $this
    ->assertRaw('Test Formatter');
}