? .DS_Store
? 775102-issue_comments_tests-A-2.patch
? 775102-issue_comments_tests-A.patch
Index: project_issue.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/project_issue.test,v
retrieving revision 1.1
diff -u -p -r1.1 project_issue.test
--- project_issue.test	20 Apr 2010 18:33:06 -0000	1.1
+++ project_issue.test	20 Apr 2010 18:44:36 -0000
@@ -12,6 +12,7 @@ class ProjectIssueWebTestCase extends Pr
     // We can't call parent::setUp() with a single array argument, so we need
     // this ugly call_user_func_array().
     call_user_func_array(array($this, 'parent::setUp'), $modules);
+    variable_set('comment_preview_project_issue', FALSE);
   }
 
   /**
@@ -19,7 +20,7 @@ class ProjectIssueWebTestCase extends Pr
    *
    * @param stdClass $project
    *   A project node.
-   * @param array $edit
+   * @param $edit
    *   An array of form values, passed to drupalPost. Optional
    * @return
    *   An issue node.
@@ -38,8 +39,12 @@ class ProjectIssueWebTestCase extends Pr
     return $this->drupalGetNodeByTitle($edit['title']);
   }
 
-  function createIssueFollowup() {
-
+  function createIssueComment($issue, $edit = array()) {
+    if (empty($edit)) {
+      $edit['comment'] = $this->randomName(64);
+    }
+    $this->drupalPost('comment/reply/' . $issue->nid, $edit, t('Save'));
+    return $edit;
   }
 }
 
@@ -60,7 +65,7 @@ class ProjectIssueCreationTestCase exten
   }
 
   /**
-   * Test the creation of project issues and the display of issue properties.
+   * Test the creation of projects and the display of project properties.
    */
   function testProjectIssueCreation() {
     $project = $this->createProject();
@@ -73,6 +78,61 @@ class ProjectIssueCreationTestCase exten
 
     $this->assertText($issue->title, t('Title found'));
     $this->assertText($issue->body, t('Body found'));
-    /// @todo We need to assert the other issue metadata fields here, too.
+  }
+}
+
+class ProjectIssueCommentTestCase extends ProjectIssueWebTestCase {
+  public static function getInfo() {
+    return array(
+      'name' => 'Project issue comment',
+      'description' => 'Test commenting on an issue.',
+      'group' => 'Project Issue',
+    );
+  }
+
+  function setUp() {
+    parent::setUp();
+
+    $maintain_user = $this->drupalCreateUser(array('maintain projects', 'create project issues', 'access project issues', 'access projects'));
+    $this->drupalLogin($maintain_user);
+  }
+
+  /**
+   * Test the creation of issue metadata.
+   */
+  function testProjectIssueMetadata() {
+    $project = $this->createProject();
+    // Test project issue node form fields.
+    $issue = $this->createIssue($project);
+    $html = $this->drupalGet('comment/reply/' . $issue->nid);
+    $this->parse();
+    // Let's iterate over all the forms.
+    $forms = $this->xpath('//form');
+    $form = $forms[0];
+    // We try to set the fields of this form as specified in $edit.
+    $post = $upload = $edit = array();
+    $this->handleForm($post, $edit, $upload, NULL, $form);
+    $map = array(
+      'priority' => 'priority',
+      'category' => 'category',
+      'component' => 'project_info[component]',
+      'assigned' => 'project_info[assigned]',
+      'pid' => 'project_info[pid]',
+    );
+    foreach ($map as $issue_key => $post_key) {
+      $this->assertEqual($issue->project_issue[$issue_key], $post[$post_key], t('Making sure comment form is correct'));
+    }
+  }
+
+  /**
+   * Test the creation of issue comments.
+   */
+  function testProjectIssueComment() {
+    $project = $this->createProject();
+    // Test project issue node form fields.
+    $issue = $this->createIssue($project);
+    $comment = $this->createIssueComment($issue);
+
+    $this->assertText($comment['comment'], t('Body found'));
   }
 }
