/[drupal]/contributions/modules/geshifilter/tests/geshifilter.admin.test
ViewVC logotype

Contents of /contributions/modules/geshifilter/tests/geshifilter.admin.test

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Sat Jul 4 09:49:00 2009 UTC (4 months, 3 weeks ago) by soxofaan
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +7 -2 lines
File MIME type: text/x-php
#455564: added [[code]] tag style and refactored bracket settings code
1 <?php
2 // $Id: geshifilter.admin.test,v 1.1 2008/04/28 22:52:17 soxofaan Exp $
3
4 // @todo: test the tag style widget, both on general settings form and format specific form: at least one tag style should be selected.
5
6 /**
7 * Funcional tests for the GeSHi filter administration.
8 */
9 class GeshiFilterAdministrationTest extends DrupalTestCase {
10
11 /**
12 * A global filter adminstrator
13 */
14 var $filter_admin_user;
15
16 /**
17 * The id of the input format with only GeSHi filter in it
18 */
19 var $input_format_id;
20
21 /**
22 * Drupal SimpleTest method: return metadata about the test.
23 */
24 function get_info() {
25 return array(
26 'name' => t('GeSHi filter administration'),
27 'desc' => t('Test the GeSHi filter administration.'),
28 'group' => t('GeSHi module'),
29 );
30 }
31
32 /**
33 * SimpleTest core method: code run before each and every test method.
34 *
35 * Optional. You only need this if you have setup tasks.
36 */
37 function setUp() {
38 // Always call the setUp() function from the parent class.
39 parent::setUp();
40
41 // Make sure that Geshi filter module is enabled.
42 $this->drupalModuleEnable('geshifilter');
43
44 // Create a filter admin user
45 $permissions = array('administer filters', 'administer site configuration');
46 $this->filter_admin_user = $this->drupalCreateUserRolePerm($permissions);
47
48 // log in with filter admin user
49 $this->drupalLoginUser($this->filter_admin_user);
50
51 // add an input format with only geshi filter
52 $edit = array(
53 'name' => $this->randomName(10, 'inputformat_'),
54 'filters[geshifilter/0]' => TRUE,
55 'roles[2]' => TRUE,
56 );
57 $this->drupalPost('admin/settings/filters/add', $edit, t('Save configuration'));
58 // store the format id of the created input format
59 $this->input_format_id = db_result(db_query("SELECT format FROM {filter_formats} WHERE name = '%s'", $edit['name']));
60 $this->assertTrue($this->input_format_id, t('Input format id (%s)'));
61
62 // set some default GeSHi filter admin settings
63 $this->drupalVariableSet('geshifilter_format_specific_options', FALSE);
64 $this->drupalVariableSet('geshifilter_tag_styles', array(
65 GESHIFILTER_BRACKETS_ANGLE => GESHIFILTER_BRACKETS_ANGLE,
66 GESHIFILTER_BRACKETS_SQUARE => GESHIFILTER_BRACKETS_SQUARE,
67 ));
68 $this->drupalVariableSet('geshifilter_default_line_numbering', GESHIFILTER_LINE_NUMBERS_DEFAULT_NONE);
69
70 }
71
72 /**
73 * SimpleTest core method: code run after each and every test method.
74 *
75 * Optional. You only need this if you have setup tasks.
76 */
77 function tearDown() {
78 // remove input format
79 $this->drupalPost('admin/settings/filters/delete/'. $this->input_format_id, array(), t('Delete'));
80
81 // Always call the tearDown() function from the parent class.
82 parent::tearDown();
83 }
84
85 /**
86 * Check tag unicity: tags should differ between languages and from generic tags
87 */
88 function test_tag_unicity() {
89 // enable some languages first
90 $this->drupalVariableSet('geshifilter_language_enabled_php', TRUE);
91 $this->drupalVariableSet('geshifilter_language_enabled_python', TRUE);
92
93 // first round: without format specific tag options
94 $this->drupalVariableSet('geshifilter_format_specific_options', FALSE);
95 $this->drupalVariableSet('geshifilter_tags', 'code blockcode generictag');
96
97 // a language tag should differ from the generic tags
98 $form_values = array(
99 'geshifilter_language_tags_php' => 'php generictag',
100 );
101 $this->drupalPost('admin/settings/geshifilter/languages', $form_values, t('Save configuration'));
102 $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)'));
103
104 // language tags should differ between languages
105 $form_values = array(
106 'geshifilter_language_tags_php' => 'php languagetag',
107 'geshifilter_language_tags_python' => 'languagetag python',
108 );
109 $this->drupalPost('admin/settings/geshifilter/languages/all', $form_values, t('Save configuration'));
110 $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)'));
111
112 // second round: with format specific tag options
113 $this->drupalVariableSet('geshifilter_format_specific_options', TRUE);
114 $this->drupalVariableSet('geshifilter_tags_' . $this->input_format_id, 'code blockcode generictag');
115
116 // a language tag should differ from the generic tags
117 $form_values = array(
118 'geshifilter_language_tags_php_' . $this->input_format_id => 'php generictag',
119 );
120 $this->drupalPost('admin/settings/filters/' . $this->input_format_id . '/configure', $form_values, t('Save configuration'));
121 $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)'));
122
123 // language tags should differ between languages
124 $form_values = array(
125 'geshifilter_language_tags_php_' . $this->input_format_id => 'php languagetag',
126 'geshifilter_language_tags_python_' . $this->input_format_id => 'languagetag python',
127 );
128 $this->drupalPost('admin/settings/filters/' . $this->input_format_id . '/configure', $form_values, t('Save configuration'));
129 $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)'));
130
131 }
132
133 }

  ViewVC Help
Powered by ViewVC 1.1.2