t('Basic talk tests'), 'desc' => t('Some basic tests for the talk module, including going to the talk page and making sure the comment shows up.'), 'group' => t('Talk tests'), ); } /** * Implementation of setUp. This will be run when we're setting up for the tests automatically. */ function setUp() { parent::setUp(); // Enable the talk module and its dependencies. $this->drupalModuleEnable('comment'); $this->drupalModuleEnable('talk'); // Create a node type, and enable the talk module for that node type. $node_type = $this->drupalCreateContentType(); $this->_talkType = $node_type->type; // This will automatically be reverted to whatever it was before the test took place after the test is over. $this->drupalVariableSet('comment_talk_'. $node_type->type, TRUE); // We don't want to deal with comment previews. $this->drupalVariableSet('comment_preview_'. $node_type->type, COMMENT_PREVIEW_OPTIONAL); // Set the talk title to something unique. $talk_title = $this->randomName(); $this->_talkTitle = $talk_title; $this->drupalVariableSet('talk_title', $talk_title); // Create and login a user with the appropriate permissions. $permissions = array('access content', 'access comments', 'post comments', 'post comments without approval'); $user = $this->drupalCreateUserRolePerm($permissions); $this->drupalLoginUser($user); } /** * Now, an actual test! * This test will post a comment in our talk-nodetype, and make sure it shows up on the */ function testTalkCommentAppears() { // Create a node to test with. $settings = array(); $settings['type'] = $this->_talkType; $node = $this->drupalCreateNode($settings); // Navigate to the node page. $this->drupalGet('node/'. $node->nid); // Click the link provided by the talk module. $this->clickLink(t('Add new comment')); // Now, post a comment. $edit = array(); $subject = $this->randomName(); $comment = $this->randomName(30); $edit['subject'] = $subject; $edit['comment'] = $comment; $this->drupalPost('comment/reply/'. $node->nid, $edit, t('Save')); // Make the actual assertions here. $this->assertText($subject, t('Make sure that the subject of the comment appears')); $this->assertText($comment, t('Make sure the body of the comment appears')); $this->assertText($this->_talkTitle, t('Make sure the talk title appears')); } /** * Implementation of tearDown. This will be run when we're finished with our tests. */ function tearDown() { // We don't actually need to do anything. But if we wanted to, we could! parent::tearDown(); } }