function GeshiFilterTest::setUp in GeSHi Filter for syntax highlighting 6
Same name and namespace in other branches
- 5.2 tests/geshifilter.test \GeshiFilterTest::setUp()
- 7 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 176 - Tests for the GeSHi filter module.
Class
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 input format with only geshi filter
$edit = array(
'name' => $this
->randomName(10, 'inputformat_'),
'filters[geshifilter/0]' => TRUE,
'filters[filter/0]' => FALSE,
'filters[filter/1]' => FALSE,
'filters[filter/2]' => FALSE,
'filters[filter/3]' => FALSE,
'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('Valid input format id'));
// 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';
}