function GeshiFilterTest::setUp in GeSHi Filter for syntax highlighting 5.2
Same name and namespace in other branches
- 6 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.
File
- tests/
geshifilter.test, line 39
Class
- GeshiFilterTest
- Unit tests for the GeSHi filter module.
Code
function setUp() {
// Always call the setUp() function from the parent class.
parent::setUp();
// Make sure that Geshi filter module is enabled.
$this
->drupalModuleEnable('geshifilter');
// Disable CAPTCHA module so users can post without trouble (just in case)
$this
->drupalModuleDisable('captcha');
// Create a filter admin user
$permissions = array(
'administer filters',
'access devel information',
);
$this->filter_admin_user = $this
->drupalCreateUserRolePerm($permissions);
// Create a normal user for page creation
$permissions = array(
'access devel information',
'edit own page content',
'create page content',
);
$this->normal_user = $this
->drupalCreateUserRolePerm($permissions);
// log in with filter admin user
$this
->drupalLoginUser($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
->drupalPostRequest('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
$this
->drupalVariableSet('geshifilter_format_specific_options', FALSE);
$this
->drupalVariableSet('geshifilter_brackets', GESHIFILTER_BRACKETS_BOTH);
$this
->drupalVariableSet('geshifilter_default_line_numbering', GESHIFILTER_LINE_NUMBERS_DEFAULT_NONE);
// log out as filter admin
$this
->drupalGet(url('logout', NULL, NULL, TRUE));
// log in as the normal user for adding pages
$this
->drupalLoginUser($this->normal_user);
// include GeSHi filtering functions
require_once drupal_get_path('module', 'geshifilter') . '/geshifilter.pages.inc';
}