diff options
Diffstat (limited to 'modules/forum/forum.test')
-rw-r--r-- | modules/forum/forum.test | 98 |
1 files changed, 69 insertions, 29 deletions
diff --git a/modules/forum/forum.test b/modules/forum/forum.test index 612b09cff..d78d962de 100644 --- a/modules/forum/forum.test +++ b/modules/forum/forum.test @@ -5,14 +5,49 @@ * Tests for forum.module. */ +/** + * Provides automated tests for the Forum module. + */ class ForumTestCase extends DrupalWebTestCase { + + /** + * A user with various administrative privileges. + */ protected $admin_user; + + /** + * A user that can create forum topics and edit its own topics. + */ protected $edit_own_topics_user; + + /** + * A user that can create, edit, and delete forum topics. + */ protected $edit_any_topics_user; + + /** + * A user with no special privileges. + */ protected $web_user; + + /** + * An array representing a container. + */ protected $container; + + /** + * An array representing a forum. + */ protected $forum; + + /** + * An array representing a root forum. + */ protected $root_forum; + + /** + * An array of forum topic node IDs. + */ protected $nids; public static function getInfo() { @@ -23,9 +58,6 @@ class ForumTestCase extends DrupalWebTestCase { ); } - /** - * Enable modules and create users with specific permissions. - */ function setUp() { parent::setUp('taxonomy', 'comment', 'forum'); // Create users. @@ -53,12 +85,12 @@ class ForumTestCase extends DrupalWebTestCase { } /** - * Tests disabling and re-enabling forum. + * Tests disabling and re-enabling the Forum module. */ function testEnableForumField() { $this->drupalLogin($this->admin_user); - // Disable the forum module. + // Disable the Forum module. $edit = array(); $edit['modules[Core][forum][enable]'] = FALSE; $this->drupalPost('admin/modules', $edit, t('Save configuration')); @@ -66,7 +98,7 @@ class ForumTestCase extends DrupalWebTestCase { module_list(TRUE); $this->assertFalse(module_exists('forum'), t('Forum module is not enabled.')); - // Attempt to re-enable the forum module and ensure it does not try to + // Attempt to re-enable the Forum module and ensure it does not try to // recreate the taxonomy_forums field. $edit = array(); $edit['modules[Core][forum][enable]'] = 'forum'; @@ -77,7 +109,7 @@ class ForumTestCase extends DrupalWebTestCase { } /** - * Login users, create forum nodes, and test forum functionality through the admin and user interfaces. + * Tests forum functionality through the admin and user interfaces. */ function testForum() { //Check that the basic forum install creates a default forum topic @@ -168,7 +200,10 @@ class ForumTestCase extends DrupalWebTestCase { } /** - * Forum nodes should not be created without choosing forum from select list. + * Tests that forum nodes can't be added without a parent. + * + * Verifies that forum nodes are not created without choosing "forum" from the + * select list. */ function testAddOrphanTopic() { // Must remove forum topics to test creating orphan topics. @@ -190,9 +225,10 @@ class ForumTestCase extends DrupalWebTestCase { } /** - * Run admin tests on the admin user. + * Runs admin tests on the admin user. * - * @param object $user The logged in user. + * @param object $user + * The logged in user. */ private function doAdminTests($user) { // Login the user. @@ -270,7 +306,7 @@ class ForumTestCase extends DrupalWebTestCase { } /** - * Edit the forum taxonomy. + * Edits the forum taxonomy. */ function editForumTaxonomy() { // Backup forum taxonomy. @@ -308,15 +344,16 @@ class ForumTestCase extends DrupalWebTestCase { } /** - * Create a forum container or a forum. + * Creates a forum container or a forum. * * @param $type - * Forum type (forum container or forum). + * The forum type (forum container or forum). * @param $parent - * Forum parent (default = 0 = a root forum; >0 = a forum container or + * The forum parent. This defaults to 0, indicating a root forum. * another forum). + * * @return - * taxonomy_term_data created. + * The created taxonomy term data. */ function createForum($type, $parent = 0) { // Generate a random name/description. @@ -349,7 +386,7 @@ class ForumTestCase extends DrupalWebTestCase { } /** - * Delete a forum. + * Deletes a forum. * * @param $tid * The forum ID. @@ -370,7 +407,7 @@ class ForumTestCase extends DrupalWebTestCase { } /** - * Run basic tests on the indicated user. + * Runs basic tests on the indicated user. * * @param $user * The logged in user. @@ -389,15 +426,15 @@ class ForumTestCase extends DrupalWebTestCase { } /** - * Create forum topic. + * Creates forum topic. * * @param array $forum - * Forum array. + * A forum array. * @param boolean $container - * True if $forum is a container. + * TRUE if $forum is a container; FALSE otherwise. * * @return object - * Topic node created. + * The created topic node. */ function createForumTopic($forum, $container = FALSE) { // Generate a random subject/body. @@ -439,7 +476,7 @@ class ForumTestCase extends DrupalWebTestCase { } /** - * Verify the logged in user has access to a forum nodes. + * Verifies that the logged in user has access to a forum nodes. * * @param $node_user * The user who creates the node. @@ -519,10 +556,12 @@ class ForumTestCase extends DrupalWebTestCase { } /** - * Verify display of forum page. + * Verifies display of forum page. * * @param $forum - * A row from taxonomy_term_data table in array. + * A row from the taxonomy_term_data table in an array. + * @param $parent + * (optional) An array representing the forum's parent. */ private function verifyForumView($forum, $parent = NULL) { // View forum page. @@ -542,9 +581,10 @@ class ForumTestCase extends DrupalWebTestCase { } /** - * Generate forum topics to test display of active forum block. + * Generates forum topics to test the display of an active forum block. * - * @param array $forum Forum array (a row from taxonomy_term_data table). + * @param array $forum + * The foorum array (a row from taxonomy_term_data table). */ private function generateForumTopics($forum) { $this->nids = array(); @@ -555,10 +595,10 @@ class ForumTestCase extends DrupalWebTestCase { } /** - * View forum topics to test display of active forum block. + * Views forum topics to test the display of an active forum block. * - * @todo The logic here is completely incorrect, since the active - * forum topics block is determined by comments on the node, not by views. + * @todo The logic here is completely incorrect, since the active forum topics + * block is determined by comments on the node, not by views. * @todo DIE * * @param $nids |