public function CommentAttributesTest::testCommentReplyOfRdfaMarkup

Tests RDF comment replies.

File

drupal/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php, line 133
Contains Drupal\rdf\Tests\CommentAttributesTest.

Class

CommentAttributesTest
Tests the RDFa markup of comments.

Namespace

Drupal\rdf\Tests

Code

public function testCommentReplyOfRdfaMarkup() {

  // Posts comment #1 on behalf of registered user.
  $this
    ->drupalLogin($this->web_user);
  $comment_1 = $this
    ->saveComment($this->node->nid, $this->web_user->uid);
  $comment_1_uri = url('comment/' . $comment_1
    ->id(), array(
    'absolute' => TRUE,
  ));

  // Posts a reply to the first comment.
  $comment_2 = $this
    ->saveComment($this->node->nid, $this->web_user->uid, NULL, $comment_1
    ->id());
  $comment_2_uri = url('comment/' . $comment_2
    ->id(), array(
    'absolute' => TRUE,
  ));
  $parser = new \EasyRdf_Parser_Rdfa();
  $graph = new \EasyRdf_Graph();
  $parser
    ->parse($graph, $this
    ->drupalGet('node/' . $this->node->nid), 'rdfa', $this->base_uri);

  // Tests the reply_of relationship of a first level comment.
  $expected_value = array(
    'type' => 'uri',
    'value' => $this->node_uri,
  );
  $this
    ->assertTrue($graph
    ->hasProperty($comment_1_uri, 'http://rdfs.org/sioc/ns#reply_of', $expected_value), 'Comment relation to its node found in RDF output (sioc:reply_of).');

  // Tests the reply_of relationship of a second level comment.
  $expected_value = array(
    'type' => 'uri',
    'value' => $this->node_uri,
  );
  $this
    ->assertTrue($graph
    ->hasProperty($comment_2_uri, 'http://rdfs.org/sioc/ns#reply_of', $expected_value), 'Comment relation to its node found in RDF output (sioc:reply_of).');
  $expected_value = array(
    'type' => 'uri',
    'value' => $comment_1_uri,
  );
  $this
    ->assertTrue($graph
    ->hasProperty($comment_2_uri, 'http://rdfs.org/sioc/ns#reply_of', $expected_value), 'Comment relation to its parent comment found in RDF output (sioc:reply_of).');
}