You are here

public function CommentAttributesTest::testCommentReplyOfRdfaMarkup in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/rdf/src/Tests/CommentAttributesTest.php \Drupal\rdf\Tests\CommentAttributesTest::testCommentReplyOfRdfaMarkup()

Tests RDF comment replies.

File

core/modules/rdf/src/Tests/CommentAttributesTest.php, line 213
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->webUser);
  $comment_1 = $this
    ->saveComment($this->node
    ->id(), $this->webUser
    ->id());
  $comment_1_uri = $comment_1
    ->url('canonical', [
    'absolute' => TRUE,
  ]);

  // Posts a reply to the first comment.
  $comment_2 = $this
    ->saveComment($this->node
    ->id(), $this->webUser
    ->id(), NULL, $comment_1
    ->id());
  $comment_2_uri = $comment_2
    ->url('canonical', [
    'absolute' => TRUE,
  ]);
  $parser = new \EasyRdf_Parser_Rdfa();
  $graph = new \EasyRdf_Graph();
  $parser
    ->parse($graph, $this
    ->drupalGet('node/' . $this->node
    ->id()), 'rdfa', $this->baseUri);

  // Tests the reply_of relationship of a first level comment.
  $expected_value = array(
    'type' => 'uri',
    'value' => $this->nodeUri,
  );
  $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->nodeUri,
  );
  $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).');
}