You are here

function GeshiFilterAdministrationTest::test_tag_unicity in GeSHi Filter for syntax highlighting 7

Same name and namespace in other branches
  1. 6 geshifilter.test \GeshiFilterAdministrationTest::test_tag_unicity()

Check tag unicity: tags should differ between languages and from generic tags

File

./geshifilter.test, line 95
Tests for the GeSHi filter module.

Class

GeshiFilterAdministrationTest
Funcional tests for the GeSHi filter administration.

Code

function test_tag_unicity() {

  // enable some languages first
  variable_set('geshifilter_language_enabled_php', TRUE);
  variable_set('geshifilter_language_enabled_python', TRUE);

  // first round: without format specific tag options
  variable_set('geshifilter_format_specific_options', FALSE);
  variable_set('geshifilter_tags', 'code blockcode generictag');

  // a language tag should differ from the generic tags
  $form_values = array(
    'geshifilter_language_tags_php' => 'php generictag',
  );
  $this
    ->drupalPost('admin/config/content/formats/geshifilter/languages', $form_values, t('Save configuration'));
  $this
    ->assertText(t('The language tags should differ between languages and from the generic tags.'), t('Language tags should differ from generic tags (with generic tag options)'));

  // language tags should differ between languages
  $form_values = array(
    'geshifilter_language_tags_php' => 'php languagetag',
    'geshifilter_language_tags_python' => 'languagetag python',
  );
  $this
    ->drupalPost('admin/config/content/formats/geshifilter/languages/all', $form_values, t('Save configuration'));
  $this
    ->assertText(t('The language tags should differ between languages and from the generic tags.'), t('Language tags should differ between languages (with generic tag options)'));

  // second round: with format specific tag options
  variable_set('geshifilter_format_specific_options', TRUE);
  variable_set('geshifilter_tags_' . $this->input_format_id, 'code blockcode generictag');

  // a language tag should differ from the generic tags
  $form_values = array(
    'filters[geshifilter][settings][per_language_settings][table][languages][php][geshifilter_language_tags_php_' . $this->input_format_id . ']' => 'php generictag',
  );
  $this
    ->drupalPost('admin/config/content/formats/' . $this->input_format_id, $form_values, t('Save configuration'));
  $this
    ->assertText(t('The language tags should differ between languages and from the generic tags.'), t('Language tags should differ from generic tags (with format specific tag options)'));

  // language tags should differ between languages
  $form_values = array(
    'filters[geshifilter][settings][per_language_settings][table][languages][php][geshifilter_language_tags_php_' . $this->input_format_id . ']' => 'php languagetag',
    'filters[geshifilter][settings][per_language_settings][table][languages][python][geshifilter_language_tags_python_' . $this->input_format_id . ']' => 'languagetag python',
  );
  $this
    ->drupalPost('admin/config/content/formats/' . $this->input_format_id, $form_values, t('Save configuration'));
  $this
    ->assertText(t('The language tags should differ between languages and from the generic tags.'), t('Language tags should differ between languages (with format specific tag options)'));
}