Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/7.x' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
lattera committed Jan 16, 2012
2 parents 0bc7e0d + 3cc2fc4 commit 2cf07a7
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 58 deletions.
100 changes: 50 additions & 50 deletions modules/comment/comment.test
Expand Up @@ -251,56 +251,6 @@ class CommentHelperCase extends DrupalWebTestCase {

return $match[2];
}

/**
* Tests new comment marker.
*/
public function testCommentNewCommentsIndicator() {
// Test if the right links are displayed when no comment is present for the
// node.
$this->drupalLogin($this->admin_user);
$this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => COMMENT_NODE_OPEN));
$this->drupalGet('node');
$this->assertNoLink(t('@count comments', array('@count' => 0)));
$this->assertNoLink(t('@count new comments', array('@count' => 0)));
$this->assertLink(t('Read more'));
$count = $this->xpath('//div[@id=:id]/div[@class=:class]/ul/li', array(':id' => 'node-' . $this->node->nid, ':class' => 'link-wrapper'));
$this->assertTrue(count($count) == 1, t('One child found'));

// Create a new comment. This helper function may be run with different
// comment settings so use comment_save() to avoid complex setup.
$comment = (object) array(
'cid' => NULL,
'nid' => $this->node->nid,
'node_type' => $this->node->type,
'pid' => 0,
'uid' => $this->loggedInUser->uid,
'status' => COMMENT_PUBLISHED,
'subject' => $this->randomName(),
'hostname' => ip_address(),
'language' => LANGUAGE_NONE,
'comment_body' => array(LANGUAGE_NONE => array($this->randomName())),
);
comment_save($comment);
$this->drupalLogout();

// Log in with 'web user' and check comment links.
$this->drupalLogin($this->web_user);
$this->drupalGet('node');
$this->assertLink(t('1 new comment'));
$this->clickLink(t('1 new comment'));
$this->assertRaw('<a id="new"></a>', t('Found "new" marker.'));
$this->assertTrue($this->xpath('//a[@id=:new]/following-sibling::a[1][@id=:comment_id]', array(':new' => 'new', ':comment_id' => 'comment-1')), t('The "new" anchor is positioned at the right comment.'));

// Test if "new comment" link is correctly removed.
$this->drupalGet('node');
$this->assertLink(t('1 comment'));
$this->assertLink(t('Read more'));
$this->assertNoLink(t('1 new comment'));
$this->assertNoLink(t('@count new comments', array('@count' => 0)));
$count = $this->xpath('//div[@id=:id]/div[@class=:class]/ul/li', array(':id' => 'node-' . $this->node->nid, ':class' => 'link-wrapper'));
$this->assertTrue(count($count) == 2, print_r($count, TRUE));
}
}

class CommentInterfaceTest extends CommentHelperCase {
Expand Down Expand Up @@ -472,6 +422,56 @@ class CommentInterfaceTest extends CommentHelperCase {
$this->setCommentForm(FALSE);
}

/**
* Tests new comment marker.
*/
public function testCommentNewCommentsIndicator() {
// Test if the right links are displayed when no comment is present for the
// node.
$this->drupalLogin($this->admin_user);
$this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => COMMENT_NODE_OPEN));
$this->drupalGet('node');
$this->assertNoLink(t('@count comments', array('@count' => 0)));
$this->assertNoLink(t('@count new comments', array('@count' => 0)));
$this->assertLink(t('Read more'));
$count = $this->xpath('//div[@id=:id]/div[@class=:class]/ul/li', array(':id' => 'node-' . $this->node->nid, ':class' => 'link-wrapper'));
$this->assertTrue(count($count) == 1, t('One child found'));

// Create a new comment. This helper function may be run with different
// comment settings so use comment_save() to avoid complex setup.
$comment = (object) array(
'cid' => NULL,
'nid' => $this->node->nid,
'node_type' => $this->node->type,
'pid' => 0,
'uid' => $this->loggedInUser->uid,
'status' => COMMENT_PUBLISHED,
'subject' => $this->randomName(),
'hostname' => ip_address(),
'language' => LANGUAGE_NONE,
'comment_body' => array(LANGUAGE_NONE => array($this->randomName())),
);
comment_save($comment);
$this->drupalLogout();

// Log in with 'web user' and check comment links.
$this->drupalLogin($this->web_user);
$this->drupalGet('node');
$this->assertLink(t('1 new comment'));
$this->clickLink(t('1 new comment'));
$this->assertRaw('<a id="new"></a>', t('Found "new" marker.'));
$this->assertTrue($this->xpath('//a[@id=:new]/following-sibling::a[1][@id=:comment_id]', array(':new' => 'new', ':comment_id' => 'comment-1')), t('The "new" anchor is positioned at the right comment.'));

// Test if "new comment" link is correctly removed.
$this->drupalGet('node');
$this->assertLink(t('1 comment'));
$this->assertLink(t('Read more'));
$this->assertNoLink(t('1 new comment'));
$this->assertNoLink(t('@count new comments', array('@count' => 0)));
$count = $this->xpath('//div[@id=:id]/div[@class=:class]/ul/li', array(':id' => 'node-' . $this->node->nid, ':class' => 'link-wrapper'));
$this->assertTrue(count($count) == 2, print_r($count, TRUE));
}

/**
* Tests the node comment statistics.
*/
Expand Down
12 changes: 5 additions & 7 deletions modules/search/search.api.php
Expand Up @@ -22,13 +22,11 @@
* on your module's type of content. If you want to have your content
* indexed in the standard search index, your module should also implement
* hook_update_index(). If your search type has settings, you can implement
* hook_search_admin() to add them to the search settings page. You can also
* alter the display of your module's search results by implementing
* hook_search_page(). You can use hook_form_FORM_ID_alter(), with
* FORM_ID set to 'search', to add fields to the search form (see
* node_form_search_form_alter() for an example). You can use
* hook_search_access() to limit access to searching, and hook_search_page() to
* override how search results are displayed.
* hook_search_admin() to add them to the search settings page. You can use
* hook_form_FORM_ID_alter(), with FORM_ID set to 'search_form', to add fields
* to the search form (see node_form_search_form_alter() for an example).
* You can use hook_search_access() to limit access to searching,
* and hook_search_page() to override how search results are displayed.
*
* @return
* Array with optional keys:
Expand Down
1 change: 0 additions & 1 deletion modules/tracker/tracker.test
Expand Up @@ -8,7 +8,6 @@
class TrackerTest extends DrupalWebTestCase {
protected $user;
protected $other_user;
protected $new_node;

public static function getInfo() {
return array(
Expand Down

0 comments on commit 2cf07a7

Please sign in to comment.