You are here

function GeshiFilterAdministrationTest::setUp in GeSHi Filter for syntax highlighting 6

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

SimpleTest core method: code run before each and every test method.

Optional. You only need this if you have setup tasks.

Overrides DrupalWebTestCase::setUp

File

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

Class

GeshiFilterAdministrationTest
Funcional tests for the GeSHi filter administration.

Code

function setUp() {

  // Make sure the GeSHi filter module is enabled.
  parent::setUp('geshifilter');

  // And set the path to the geshi library.
  variable_set('geshifilter_geshi_dir', 'sites/all/libraries/geshi');

  // Create a filter admin user
  $permissions = array(
    'administer filters',
    'administer site configuration',
  );
  $this->filter_admin_user = $this
    ->drupalCreateUser($permissions);

  // log in with filter admin user
  $this
    ->drupalLogin($this->filter_admin_user);

  // add an input format with only geshi filter
  $edit = array(
    'name' => $this
      ->randomName(10, 'inputformat_'),
    'filters[geshifilter/0]' => TRUE,
    'roles[2]' => TRUE,
  );
  $this
    ->drupalPost('admin/settings/filters/add', $edit, t('Save configuration'));

  // store the format id of the created input format
  $this->input_format_id = db_result(db_query("SELECT format FROM {filter_formats} WHERE name = '%s'", $edit['name']));
  $this
    ->assertTrue($this->input_format_id, t('Input format id (%s)'));

  // set some default GeSHi filter admin settings
  variable_set('geshifilter_format_specific_options', FALSE);
  variable_set('geshifilter_tag_styles', array(
    GESHIFILTER_BRACKETS_ANGLE => GESHIFILTER_BRACKETS_ANGLE,
    GESHIFILTER_BRACKETS_SQUARE => GESHIFILTER_BRACKETS_SQUARE,
  ));
  variable_set('geshifilter_default_line_numbering', GESHIFILTER_LINE_NUMBERS_DEFAULT_NONE);
}