You are here

function GeshiFilterTest::setUp in GeSHi Filter for syntax highlighting 7

Same name and namespace in other branches
  1. 5.2 tests/geshifilter.test \GeshiFilterTest::setUp()
  2. 6 geshifilter.test \GeshiFilterTest::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 178
Tests for the GeSHi filter module.

Class

GeshiFilterTest
Funcional tests for the GeSHi filter node content.

Code

function setUp() {

  // Make sure that 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',
  );
  $this->filter_admin_user = $this
    ->drupalCreateUser($permissions);

  // Create a normal user for page creation
  $permissions = array(
    'edit own page content',
    'create page content',
  );
  $this->normal_user = $this
    ->drupalCreateUser($permissions);

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

  // add an text format with only geshi filter
  $this
    ->createTextFormat('geshifilter_text_format', array(
    'geshifilter',
  ));

  // store the format id of the created text format
  $this->input_format_id = 'geshifilter_text_format';

  // set some default GeSHi filter admin settings
  // Set default highlighting mode to "do nothing".
  variable_set('geshifilter_default_highlighting', GESHIFILTER_DEFAULT_PLAINTEXT);
  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);

  // log out as filter admin
  $this
    ->drupalGet('logout');

  // log in as the normal user for adding pages
  $this
    ->drupalLogin($this->normal_user);

  // include GeSHi filtering functions
  require_once drupal_get_path('module', 'geshifilter') . '/geshifilter.pages.inc';
}