Index: modules/comment/comment.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.test,v
retrieving revision 1.92
diff -u -p -r1.92 comment.test
--- modules/comment/comment.test	8 Nov 2010 21:36:45 -0000	1.92
+++ modules/comment/comment.test	27 Nov 2010 02:29:20 -0000
@@ -249,6 +249,149 @@ class CommentHelperCase extends DrupalWe
   }
 }
 
+/**
+ * Check that appropriate links are added to nodes.
+ *
+ * Each node page should provide links for:
+ *
+ * - Add comment                              links['comment-add']
+ * - View comments (including comment-count)  links['comment']
+ * - View new comments                        links['comment-new']
+ *
+ * Each link may be non-existant, in-page or to another page, depending on the
+ * users permissions and the site configuration.
+ *
+ * Dependencies:
+ *   SETTING            LINK KEY              URL                                    OPTIONS
+ * - Cannot comment     comment_forbidden     -                                      Checks against user_access('post comments').
+ * - Add comment        comment-add           node/$node->nid#comment-form           see COMMENT_FORM_BELOW
+ * - Add comment        comment-add           comment/reply/$node->nid#comment-form  see COMMENT_FORM_SEPARATE_PAGE
+ * - View comments      comment-comments      node/$node->nid#comments               Only if comments are enabled and exist.
+ * - View new comments  comment-new-comments  node/$node->nid#new                    Only if new comments exist.
+ */
+class CommentLinksTest extends CommentHelperCase {
+
+  public $node = NULL;
+  public $comments = array();
+  public $admin_user = NULL;
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Comment links',
+      'description' => 'Test the links added by comment.',
+      'group' => 'Comment',
+    );
+  }
+
+  /**
+   * Each test expects a pre-existing node, and one or more comments.
+   */
+  function setUp() {
+    parent::setUp();
+
+    // Create an admin user.
+    $permissions = module_invoke_all('permission');
+    $this->admin_user = $this->drupalCreateUser(array_keys($permissions));
+    $this->drupalLogin($this->admin_user);
+
+    $node = array(
+      'type' => 'page',
+    );
+    $this->node = $this->drupalCreateNode($node);
+
+    // Add first comment
+    $comment_text = $this->randomName();
+    $comment = $this->postComment($this->node, $comment_text);
+
+    // Add second comment
+    $this->comments[] = $comment_text = $this->randomName();
+    $this->comments[] = $comment = $this->postComment($this->node, $comment_text);
+
+  }
+
+
+  /**
+   * Check the comment interface under the Stark theme.
+   */
+  function testCommentStark() {
+    // Switch the theme to Stark.
+    theme_enable(array('stark'));
+    variable_set('theme_default', 'stark');
+
+    $this->drupalLogin($this->admin_user);
+
+    $node = $this->node;
+    $this->drupalGet("node/{$node->nid}");
+
+
+    // Expect links to view comment / add comment.
+
+    // Look for ALL comments at node/1#comments
+    $elements = $this->xpath('//a[contains(@href, :filename)]', array(
+      ':filename' => "node/{$this->node->nid}#comments",
+    ));
+    $this->assertTrue(count($elements), "Link to comments section found.");
+
+    // Look for NEW comments at node/1#new
+    $elements = $this->xpath('//a[contains(@href, :filename)]', array(
+      ':filename' => "node/{$this->node->nid}#new",
+    ));
+    $this->assertTrue(count($elements), "Link to new-comments section found.");
+
+    // Look for ADD-COMMENT-FORM at node/1#comment-form for COMMENT_FORM_BELOW
+    // config.
+    $elements = $this->xpath('//a[contains(@href, :filename)]', array(
+      ':filename' => "node/{$this->node->nid}#comment-form",
+    ));
+    $this->assertTrue(count($elements), "Link to comment-form found.");
+  }
+
+  /**
+   * Check the comment interface under the Stark theme.
+   */
+  function testCommentStarkCOMMENT_FORM_SEPARATE_PAGE() {
+    // Switch the theme to Stark.
+    theme_enable(array('stark'));
+    variable_set('theme_default', 'stark');
+
+    // Switch to COMMENT_FORM_SEPARATE_PAGE
+    variable_set('comment_form_location_page', COMMENT_FORM_SEPARATE_PAGE);
+
+    $this->drupalLogin($this->admin_user);
+
+    $node = $this->node;
+    $this->drupalGet("node/{$node->nid}");
+
+    // Expect links to view comment / add comment.
+
+    // Look for ALL comments at node/1#comments
+    $elements = $this->xpath('//a[contains(@href, :filename)]', array(
+      ':filename' => "node/{$this->node->nid}#comments",
+    ));
+    $this->assertTrue(count($elements), "Link to comments section found.");
+
+    // Look for NEW comments at node/1#new
+    $elements = $this->xpath('//a[contains(@href, :filename)]', array(
+      ':filename' => "node/{$this->node->nid}#new",
+    ));
+    $this->assertTrue(count($elements), "Link to new-comments found.");
+
+    // There should be no ADD-COMMENT-FORM at node/1#comment-form when using
+    // COMMENT_FORM_SEPARATE_PAGE config.
+    $elements = $this->xpath('//a[contains(@href, :filename)]', array(
+      ':filename' => "node/{$this->node->nid}#comment-form",
+    ));
+    $this->assertFALSE(count($elements), "Link to on-page comment-form is not present.");
+
+    // There should be an ADD-COMMENT-FORM at comment/reply/1#comment-form when using
+    // COMMENT_FORM_SEPARATE_PAGE config.
+    $elements = $this->xpath('//a[contains(@href, :filename)]', array(
+      ':filename' => "comment/reply/{$this->node->nid}#comment-form",
+    ));
+    $this->assertTRUE(count($elements), "Link to separate-page comment-form is not present.");
+  }
+}
+
 class CommentInterfaceTest extends CommentHelperCase {
   public static function getInfo() {
     return array(
