1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* @file
|
4 |
|
|
* Tests for Forum Access module.
|
5 |
|
|
*/
|
6 |
|
|
|
7 |
|
|
require_once(drupal_get_path('module', 'forum') . '/forum.test');
|
8 |
|
|
|
9 |
|
|
/**
|
10 |
|
|
* Functional tests for the Forum module, with Forum Access (and ACL) installed.
|
11 |
|
|
*/
|
12 |
|
|
class ForumAccess00PlainTestCase extends ForumTestCase {
|
13 |
|
|
|
14 |
|
|
public static function getInfo() {
|
15 |
|
|
return array(
|
16 |
|
|
'name' => '0. Forum functionality (with FA and ACL)',
|
17 |
|
|
'description' => 'Run the Forum (!) module tests with Forum Access (and ACL) installed.',
|
18 |
|
|
'group' => 'Forum Access',
|
19 |
|
|
);
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
/**
|
23 |
|
|
* Implements setUp().
|
24 |
|
|
*/
|
25 |
|
|
function setUp($modules = array()) {
|
26 |
|
|
parent::setUp();
|
27 |
|
|
$modules = array('devel') + $modules;
|
28 |
|
|
$files = system_rebuild_module_data();
|
29 |
|
|
$available_modules = array();
|
30 |
|
|
foreach ($modules as $module) {
|
31 |
|
|
if (!empty($files[$module]) && !module_exists($module)) {
|
32 |
|
|
$available_modules[] = $module;
|
33 |
|
|
}
|
34 |
|
|
}
|
35 |
|
|
if (!empty($available_modules)) {
|
36 |
|
|
module_enable($available_modules);
|
37 |
|
|
}
|
38 |
|
|
parent::resetAll();
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
/**
|
42 |
|
|
* This test checks whether the Forum checkbox is enabled in the forum list.
|
43 |
|
|
* With Forum Access enabled, the Forum checkbox necessarily gets disabled
|
44 |
|
|
* and the test would fail.
|
45 |
|
|
*
|
46 |
|
|
* @see ForumTestCase::testEnableForumField()
|
47 |
|
|
*/
|
48 |
|
|
function testEnableForumField() {
|
49 |
|
|
$this->assertTrue(TRUE, 'Skip the testEnableForumField() test.');
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
/**
|
53 |
|
|
* This test assumes that the node/add/forum page is accessible if there
|
54 |
|
|
* are no forums defined. FA checks whether $user has Post access in any
|
55 |
|
|
* forum, and if none is found, it returns a 403. This fulfills the
|
56 |
|
|
* intention of the test.
|
57 |
|
|
*
|
58 |
|
|
* @see ForumTestCase::testAddOrphanTopic()
|
59 |
|
|
*/
|
60 |
|
|
function testAddOrphanTopic() {
|
61 |
|
|
$this->assertTrue(TRUE, 'Skip the testAddOrphanTopic() test.');
|
62 |
|
|
}
|
63 |
|
|
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
require_once(drupal_get_path('module', 'forum_access') . '/tests/forum_access_test_base.php');
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
/**
|
71 |
|
|
* Initial configuration tests for the Forum Access module.
|
72 |
|
|
*/
|
73 |
|
|
class ForumAccess11InitialConfigurationTestCase extends ForumAccessBaseTestCase {
|
74 |
|
|
|
75 |
|
|
public static function getInfo() {
|
76 |
|
|
return array(
|
77 |
|
|
'name' => '1. Forum Access Initial Configuration',
|
78 |
|
|
'description' => 'Display and verify the initial configuration for all ensuing tests (roles, permissions, users, Forum Access default settings in a new forum).',
|
79 |
|
|
'group' => 'Forum Access',
|
80 |
|
|
);
|
81 |
|
|
}
|
82 |
|
|
|
83 |
|
|
function testInitialConfiguration() {
|
84 |
|
|
$this->setUp2();
|
85 |
|
|
$this->pass('#########################<br />#1 - START test initial configuration @' . (time() - $this->time), '######');
|
86 |
|
|
|
87 |
|
|
// Show permissions grid.
|
88 |
|
|
$this->drupalGet('admin/people/permissions/list');
|
89 |
|
|
$this->assertResponse(200, '^^^ Permissions');
|
90 |
|
|
// Show list of users.
|
91 |
|
|
$this->drupalGet('admin/people');
|
92 |
|
|
$this->assertResponse(200);
|
93 |
|
|
// Show list of users.
|
94 |
|
|
$this->drupalGet('admin/people', array('query' => array('sort' => 'asc', 'order' => drupal_encode_path(t('Username')))));
|
95 |
|
|
$this->assertResponse(200, '^^^ Users');
|
96 |
|
|
// Show list of forums aka Forum Overview (only 'General discussion' at this point).
|
97 |
|
|
$this->drupalGet('forum');
|
98 |
|
|
$this->assertResponse(200, '^^^ Forums');
|
99 |
|
|
// Show administrative list of forums.
|
100 |
|
|
$this->drupalGet('admin/structure/forum');
|
101 |
|
|
$this->assertResponse(200, '^^^ Forum Administration Overview');
|
102 |
|
|
|
103 |
|
|
// Show default forum settings after installation of FA.
|
104 |
|
|
$this->drupalGet('admin/structure/forum/edit/forum/1');
|
105 |
|
|
$this->assertResponse(200, '^^^ Forum 1 Administration');
|
106 |
|
|
|
107 |
|
|
// Verify the checked state of the checkboxes.
|
108 |
|
|
foreach (array($this->webmaster_rid, $this->forum_admin_rid, $this->edit_any_content_rid, $this->edit_own_content_rid, $this->create_content_rid) as $rid) {
|
109 |
|
|
foreach ($this->accesses as $access) {
|
110 |
|
|
$this->assertNoFieldChecked("edit-forum-access-grants-checkboxes-$access-$rid", "Role $rid does NOT have '$access'.");
|
111 |
|
|
}
|
112 |
|
|
}
|
113 |
|
|
$this->assertNoFieldChecked("edit-forum-access-grants-checkboxes-view-3", "administrator does NOT have 'view'.");
|
114 |
|
|
$this->assertNoFieldChecked("edit-forum-access-grants-checkboxes-create-3", "administrator does NOT have 'create'.");
|
115 |
|
|
$this->assertFieldChecked( "edit-forum-access-grants-checkboxes-update-3", "administrator has 'update'.");
|
116 |
|
|
$this->assertFieldChecked( "edit-forum-access-grants-checkboxes-delete-3", "administrator has 'delete'.");
|
117 |
|
|
$this->assertFieldChecked( "edit-forum-access-grants-checkboxes-view-1", "anonymous has 'view'.");
|
118 |
|
|
$this->assertNoFieldChecked("edit-forum-access-grants-checkboxes-create-1", "anonymous does NOT have 'create'.");
|
119 |
|
|
$this->assertNoFieldChecked("edit-forum-access-grants-checkboxes-update-1", "anonymous does NOT have 'update'.");
|
120 |
|
|
$this->assertNoFieldChecked("edit-forum-access-grants-checkboxes-delete-1", "anonymous does NOT have 'delete'.");
|
121 |
|
|
$this->assertFieldChecked( "edit-forum-access-grants-checkboxes-view-2", "authenticated has 'view'.");
|
122 |
|
|
$this->assertFieldChecked( "edit-forum-access-grants-checkboxes-create-2", "authenticated has 'create'.");
|
123 |
|
|
$this->assertNoFieldChecked("edit-forum-access-grants-checkboxes-update-2", "authenticated does NOT have 'update'.");
|
124 |
|
|
$this->assertNoFieldChecked("edit-forum-access-grants-checkboxes-delete-2", "authenticated does NOT have 'delete'.");
|
125 |
|
|
|
126 |
|
|
// Verify the enabled/disabled state of the checkboxes.
|
127 |
|
|
foreach ($this->rids as $rid) {
|
128 |
|
|
foreach ($this->accesses as $access) {
|
129 |
|
|
$key = "$access-$rid";
|
130 |
|
|
if (array_search($key, array('update-3', 'delete-3')) !== FALSE) {
|
131 |
|
|
$this->assertFieldDisabled("edit-forum-access-grants-checkboxes-$key"/* , "Role $rid's '$access' checkbox is disabled." */);
|
132 |
|
|
}
|
133 |
|
|
else {
|
134 |
|
|
$this->assertFieldEnabled("edit-forum-access-grants-checkboxes-$key"/* , "Role $rid's '$access' checkbox is enabled." */);
|
135 |
|
|
}
|
136 |
|
|
}
|
137 |
|
|
}
|
138 |
|
|
|
139 |
|
|
// Remove the Drupal default forum.
|
140 |
|
|
$this->drupalGet('forum/1');
|
141 |
|
|
$this->assertResponse(200);
|
142 |
|
|
taxonomy_term_delete(1);
|
143 |
|
|
$this->drupalGet('forum/1');
|
144 |
|
|
$this->assertResponse(404);
|
145 |
|
|
$this->drupalGet('forum');
|
146 |
|
|
$this->assertResponse(200);
|
147 |
|
|
$this->assertText(t('No forums defined'), 'Drupal default forum removed.');
|
148 |
|
|
|
149 |
|
|
$this->pass('#########################<br />#1 - END test initial configuration @' . (time() - $this->time), '######');
|
150 |
|
|
}
|
151 |
|
|
|
152 |
|
|
}
|
153 |
|
|
|
154 |
|
|
|
155 |
|
|
/**
|
156 |
|
|
* Default configuration test for the Forum Access module.
|
157 |
|
|
*/
|
158 |
|
|
class ForumAccess12DefaultConfigurationTestCase extends ForumAccessBaseTestCase {
|
159 |
|
|
|
160 |
|
|
public static function getInfo() {
|
161 |
|
|
return array(
|
162 |
|
|
'name' => '2. Forum Access Default Configuration',
|
163 |
|
|
'description' => 'Test access for the default forum configuration.',
|
164 |
|
|
'group' => 'Forum Access',
|
165 |
|
|
);
|
166 |
|
|
}
|
167 |
|
|
|
168 |
|
|
function testAccess2() {
|
169 |
|
|
$this->setUp2();
|
170 |
|
|
taxonomy_term_delete(1);
|
171 |
|
|
$this->pass('#########################<br />#2 - START Default Configuration test @' . (time() - $this->time), '<a id="jump1" href="#jump2">/\<br />######<br />\/</a>');
|
172 |
|
|
|
173 |
|
|
// Create a forum with default settings.
|
174 |
|
|
//$this->drupalGet('admin/structure/forum/add/forum');
|
175 |
|
|
//$this->assertResponse(200);
|
176 |
|
|
$edit = array(
|
177 |
|
|
'name' => 'Forum 2 (Default)',
|
178 |
|
|
'description' => 'Default settings',
|
179 |
|
|
'parent[0]' => 0,
|
180 |
|
|
'weight' => '0',
|
181 |
|
|
);
|
182 |
|
|
$forum = (object) ($edit + array('tid' => 2));
|
183 |
|
|
// Create forum.
|
184 |
|
|
$this->drupalPost('admin/structure/forum/add/forum', $edit, t('Save'));
|
185 |
|
|
$this->assertResponse(200, "$forum->name added.");
|
186 |
|
|
$this->drupalGet("admin/structure/forum/edit/forum/$forum->tid");
|
187 |
|
|
$this->assertResponse(200, "^^^ $forum->name exists, with these settings.");
|
188 |
|
|
$this->drupalGet('forum');
|
189 |
|
|
$this->assertResponse(200, 'Forum Overview');
|
190 |
|
|
$this->checkForum($forum, TRUE);
|
191 |
|
|
$this->pass('#########################<br />#2 - END Default Configuration test @' . (time() - $this->time), '<a id="jump2" href="#jump3">/\<br />######<br />\/</a>');
|
192 |
|
|
}
|
193 |
|
|
|
194 |
|
|
}
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
/**
|
198 |
|
|
* Read-Only configuration test for the Forum Access module.
|
199 |
|
|
*/
|
200 |
|
|
class ForumAccess13ReadOnlyConfigurationTestCase extends ForumAccessBaseTestCase {
|
201 |
|
|
|
202 |
|
|
public static function getInfo() {
|
203 |
|
|
return array(
|
204 |
|
|
'name' => '3. Forum Access Read-Only',
|
205 |
|
|
'description' => 'Test access for the configuration with only View access given.',
|
206 |
|
|
'group' => 'Forum Access',
|
207 |
|
|
);
|
208 |
|
|
}
|
209 |
|
|
|
210 |
|
|
function testAccess3() {
|
211 |
|
|
$this->createAndCheckForum(3, 'Read-Only', 'All View checkboxes checked', array('view'));
|
212 |
|
|
}
|
213 |
|
|
}
|
214 |
|
|
|
215 |
|
|
|
216 |
|
|
/**
|
217 |
|
|
* All-OFF configuration test for the Forum Access module.
|
218 |
|
|
*/
|
219 |
|
|
class ForumAccess14AllOffConfigurationTestCase extends ForumAccessBaseTestCase {
|
220 |
|
|
|
221 |
|
|
public static function getInfo() {
|
222 |
|
|
return array(
|
223 |
|
|
'name' => '4. Forum Access All-OFF Configuration',
|
224 |
|
|
'description' => 'Test access for the configuration with all access withheld.',
|
225 |
|
|
'group' => 'Forum Access',
|
226 |
|
|
);
|
227 |
|
|
}
|
228 |
|
|
|
229 |
|
|
function testAccess4() {
|
230 |
|
|
$this->createAndCheckForum(4, 'All-OFF', 'All checkboxes cleared', array());
|
231 |
|
|
}
|
232 |
|
|
}
|
233 |
|
|
|
234 |
|
|
|
235 |
|
|
/**
|
236 |
|
|
* All-ON configuration test for the Forum Access module.
|
237 |
|
|
*/
|
238 |
|
|
class ForumAccess15AllOnConfigurationTestCase extends ForumAccessBaseTestCase {
|
239 |
|
|
|
240 |
|
|
public static function getInfo() {
|
241 |
|
|
return array(
|
242 |
|
|
'name' => '5. Forum Access All-ON Configuration',
|
243 |
|
|
'description' => 'Test access for the configuration with all access given.',
|
244 |
|
|
'group' => 'Forum Access',
|
245 |
|
|
);
|
246 |
|
|
}
|
247 |
|
|
|
248 |
|
|
function testAccess5() {
|
249 |
|
|
$this->createAndCheckForum(5, 'All-ON', 'All checkboxes checked', $this->accesses);
|
250 |
|
|
}
|
251 |
|
|
}
|
252 |
|
|
|
253 |
|
|
|
254 |
|
|
/**
|
255 |
|
|
* No-View configuration test for the Forum Access module.
|
256 |
|
|
*/
|
257 |
|
|
class ForumAccess16NoViewConfigurationTestCase extends ForumAccessBaseTestCase {
|
258 |
|
|
|
259 |
|
|
public static function getInfo() {
|
260 |
|
|
return array(
|
261 |
|
|
'name' => '6. Forum Access No-View',
|
262 |
|
|
'description' => 'Test access for the configuration without View access (blocks all other access!).',
|
263 |
|
|
'group' => 'Forum Access',
|
264 |
|
|
);
|
265 |
|
|
}
|
266 |
|
|
|
267 |
|
|
function testAccess6() {
|
268 |
|
|
$accesses = $this->accesses;
|
269 |
|
|
array_shift($accesses);
|
270 |
|
|
$this->createAndCheckForum(6, 'No-View', 'All checkboxes checked except View column', $accesses);
|
271 |
|
|
}
|
272 |
|
|
}
|