View source
<?php
require_once drupal_get_path('module', 'forum') . '/forum.test';
class ForumAccess00PlainTestCase extends ForumTestCase {
public static function getInfo() {
return array(
'name' => '0. Forum functionality (with FA and ACL)',
'description' => 'Run the Forum (!) module tests with Forum Access (and ACL) installed.',
'group' => 'Forum Access',
);
}
function setUp($modules = array()) {
parent::setUp();
$modules = array(
'devel',
) + $modules;
$files = system_rebuild_module_data();
$available_modules = array();
foreach ($modules as $module) {
if (!empty($files[$module]) && !module_exists($module)) {
$available_modules[] = $module;
}
}
if (!empty($available_modules)) {
module_enable($available_modules);
}
parent::resetAll();
}
function testEnableForumField() {
$this
->assertTrue(TRUE, 'Skip the testEnableForumField() test.');
}
function testAddOrphanTopic() {
$this
->assertTrue(TRUE, 'Skip the testAddOrphanTopic() test.');
}
}
require_once drupal_get_path('module', 'forum_access') . '/tests/forum_access_test_base.php';
class ForumAccess11InitialConfigurationTestCase extends ForumAccessBaseTestCase {
public static function getInfo() {
return array(
'name' => '1. Forum Access Initial Configuration',
'description' => 'Display and verify the initial configuration for all ensuing tests (roles, permissions, users, Forum Access default settings in a new forum).',
'group' => 'Forum Access',
);
}
function testInitialConfiguration() {
$this
->setUp2();
$this
->pass('#########################<br />#1 - START test initial configuration @' . (time() - $this->time), '######');
$this
->drupalGet('admin/people/permissions/list');
$this
->assertResponse(200, '^^^ Permissions');
$this
->drupalGet('admin/people');
$this
->assertResponse(200);
$this
->drupalGet('admin/people', array(
'query' => array(
'sort' => 'asc',
'order' => drupal_encode_path(t('Username')),
),
));
$this
->assertResponse(200, '^^^ Users');
$this
->drupalGet('forum');
$this
->assertResponse(200, '^^^ Forums');
$this
->drupalGet('admin/structure/forum');
$this
->assertResponse(200, '^^^ Forum Administration Overview');
$this
->drupalGet('admin/structure/forum/edit/forum/1');
$this
->assertResponse(200, '^^^ Forum 1 Administration');
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) {
foreach ($this->accesses as $access) {
$this
->assertNoFieldChecked("edit-forum-access-grants-checkboxes-{$access}-{$rid}", "Role {$rid} does NOT have '{$access}'.");
}
}
$this
->assertNoFieldChecked("edit-forum-access-grants-checkboxes-view-3", "administrator does NOT have 'view'.");
$this
->assertNoFieldChecked("edit-forum-access-grants-checkboxes-create-3", "administrator does NOT have 'create'.");
$this
->assertFieldChecked("edit-forum-access-grants-checkboxes-update-3", "administrator has 'update'.");
$this
->assertFieldChecked("edit-forum-access-grants-checkboxes-delete-3", "administrator has 'delete'.");
$this
->assertFieldChecked("edit-forum-access-grants-checkboxes-view-1", "anonymous has 'view'.");
$this
->assertNoFieldChecked("edit-forum-access-grants-checkboxes-create-1", "anonymous does NOT have 'create'.");
$this
->assertNoFieldChecked("edit-forum-access-grants-checkboxes-update-1", "anonymous does NOT have 'update'.");
$this
->assertNoFieldChecked("edit-forum-access-grants-checkboxes-delete-1", "anonymous does NOT have 'delete'.");
$this
->assertFieldChecked("edit-forum-access-grants-checkboxes-view-2", "authenticated has 'view'.");
$this
->assertFieldChecked("edit-forum-access-grants-checkboxes-create-2", "authenticated has 'create'.");
$this
->assertNoFieldChecked("edit-forum-access-grants-checkboxes-update-2", "authenticated does NOT have 'update'.");
$this
->assertNoFieldChecked("edit-forum-access-grants-checkboxes-delete-2", "authenticated does NOT have 'delete'.");
foreach ($this->rids as $rid) {
foreach ($this->accesses as $access) {
$key = "{$access}-{$rid}";
if (array_search($key, array(
'update-3',
'delete-3',
)) !== FALSE) {
$this
->assertFieldDisabled("edit-forum-access-grants-checkboxes-{$key}");
}
else {
$this
->assertFieldEnabled("edit-forum-access-grants-checkboxes-{$key}");
}
}
}
$this
->drupalGet('forum/1');
$this
->assertResponse(200);
taxonomy_term_delete(1);
$this
->drupalGet('forum/1');
$this
->assertResponse(404);
$this
->drupalGet('forum');
$this
->assertResponse(200);
$this
->assertText(t('No forums defined'), 'Drupal default forum removed.');
$this
->pass('#########################<br />#1 - END test initial configuration @' . (time() - $this->time), '######');
}
}
class ForumAccess12DefaultConfigurationTestCase extends ForumAccessBaseTestCase {
public static function getInfo() {
return array(
'name' => '2. Forum Access Default Configuration',
'description' => 'Test access for the default forum configuration.',
'group' => 'Forum Access',
);
}
function testAccess2() {
$this
->setUp2();
taxonomy_term_delete(1);
$this
->pass('#########################<br />#2 - START Default Configuration test @' . (time() - $this->time), '<a id="jump1" href="#jump2">/\\<br />######<br />\\/</a>');
$edit = array(
'name' => 'Forum 2 (Default)',
'description' => 'Default settings',
'parent[0]' => 0,
'weight' => '0',
);
$forum = (object) ($edit + array(
'tid' => 2,
));
$this
->drupalPost('admin/structure/forum/add/forum', $edit, t('Save'));
$this
->assertResponse(200, "{$forum->name} added.");
$this
->drupalGet("admin/structure/forum/edit/forum/{$forum->tid}");
$this
->assertResponse(200, "^^^ {$forum->name} exists, with these settings.");
$this
->drupalGet('forum');
$this
->assertResponse(200, 'Forum Overview');
$this
->checkForum($forum, TRUE);
$this
->pass('#########################<br />#2 - END Default Configuration test @' . (time() - $this->time), '<a id="jump2" href="#jump3">/\\<br />######<br />\\/</a>');
}
}
class ForumAccess13ReadOnlyConfigurationTestCase extends ForumAccessBaseTestCase {
public static function getInfo() {
return array(
'name' => '3. Forum Access Read-Only',
'description' => 'Test access for the configuration with only View access given.',
'group' => 'Forum Access',
);
}
function testAccess3() {
$this
->createAndCheckForum(3, 'Read-Only', 'All View checkboxes checked', array(
'view',
));
}
}
class ForumAccess14AllOffConfigurationTestCase extends ForumAccessBaseTestCase {
public static function getInfo() {
return array(
'name' => '4. Forum Access All-OFF Configuration',
'description' => 'Test access for the configuration with all access withheld.',
'group' => 'Forum Access',
);
}
function testAccess4() {
$this
->createAndCheckForum(4, 'All-OFF', 'All checkboxes cleared', array());
}
}
class ForumAccess15AllOnConfigurationTestCase extends ForumAccessBaseTestCase {
public static function getInfo() {
return array(
'name' => '5. Forum Access All-ON Configuration',
'description' => 'Test access for the configuration with all access given.',
'group' => 'Forum Access',
);
}
function testAccess5() {
$this
->createAndCheckForum(5, 'All-ON', 'All checkboxes checked', $this->accesses);
}
}
class ForumAccess16NoViewConfigurationTestCase extends ForumAccessBaseTestCase {
public static function getInfo() {
return array(
'name' => '6. Forum Access No-View',
'description' => 'Test access for the configuration without View access (blocks all other access!).',
'group' => 'Forum Access',
);
}
function testAccess6() {
$accesses = $this->accesses;
array_shift($accesses);
$this
->createAndCheckForum(6, 'No-View', 'All checkboxes checked except View column', $accesses);
}
}