public function CommentAttributesTest::testNumberOfCommentsRdfaMarkup

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

File

drupal/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php, line 70
Definition of Drupal\rdf\Tests\CommentAttributesTest.

Class

CommentAttributesTest
Tests the RDFa markup of comments.

Namespace

Drupal\rdf\Tests

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');
  $comment_count_teaser = $this
    ->xpath('//div[contains(@typeof, "sioc:Item")]//li[contains(@class, "comment-comments")]/a[contains(@property, "sioc:num_replies") and contains(@content, "2") and @datatype="xsd:integer"]');
  $this
    ->assertTrue(!empty($comment_count_teaser), 'RDFa markup for the number of comments found on teaser view.');
  $comment_count_link = $this
    ->xpath('//div[@about=:url]//a[contains(@property, "sioc:num_replies") and @rel=""]', array(
    ':url' => url("node/{$this->node1->nid}"),
  ));
  $this
    ->assertTrue(!empty($comment_count_link), 'Empty rel attribute found in comment count link.');

  // Tests number of comments in full node view.
  $this
    ->drupalGet('node/' . $this->node1->nid);
  $node_url = url('node/' . $this->node1->nid);
  $comment_count_teaser = $this
    ->xpath('/html/head/meta[@about=:node-url and @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.');
}