You are here

public function RdfCommentAttributesTestCase::testNumberOfCommentsRdfaMarkup in Drupal 7

Tests the presence of the RDFa markup for the number of comments.

File

modules/rdf/rdf.test, line 456
Tests for rdf.module.

Class

RdfCommentAttributesTestCase

Code

public function testNumberOfCommentsRdfaMarkup() {

  // Posts 2 comments as a registered user.
  $this
    ->drupalLogin($this->web_user);
  $this
    ->postComment($this->node1, $this
    ->randomName(), $this
    ->randomName());
  $this
    ->postComment($this->node1, $this
    ->randomName(), $this
    ->randomName());

  // Tests number of comments in teaser view.
  $this
    ->drupalGet('node');
  $node_url = url('node/' . $this->node1->nid);
  $comment_count_teaser = $this
    ->xpath('//div[@about=:node-url]/span[@property="sioc:num_replies" and @content="2" and @datatype="xsd:integer"]', array(
    ':node-url' => $node_url,
  ));
  $this
    ->assertTrue(!empty($comment_count_teaser), 'RDFa markup for the number of comments found on teaser view.');

  // Tests number of comments in full node view.
  $this
    ->drupalGet('node/' . $this->node1->nid);
  $comment_count_teaser = $this
    ->xpath('//div[@about=:node-url]/span[@property="sioc:num_replies" and @content="2" and @datatype="xsd:integer"]', array(
    ':node-url' => $node_url,
  ));
  $this
    ->assertTrue(!empty($comment_count_teaser), 'RDFa markup for the number of comments found on full node view.');
}