function CommentAttributesTest::testCommentReplyOfRdfaMarkup

Same name in other branches
  1. 8.9.x core/modules/rdf/tests/src/Functional/CommentAttributesTest.php \Drupal\Tests\rdf\Functional\CommentAttributesTest::testCommentReplyOfRdfaMarkup()

Tests RDF comment replies.

File

core/modules/rdf/tests/src/Functional/CommentAttributesTest.php, line 219

Class

CommentAttributesTest
Tests the RDFa markup of comments.

Namespace

Drupal\Tests\rdf\Functional

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->toUrl('canonical', [
        'absolute' => TRUE,
    ])
        ->toString();
    // 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->toUrl('canonical', [
        'absolute' => TRUE,
    ])
        ->toString();
    // Tests the reply_of relationship of a first level comment.
    $this->drupalGet($this->node
        ->toUrl());
    $expected_value = [
        'type' => 'uri',
        'value' => $this->nodeUri,
    ];
    $this->assertTrue($this->hasRdfProperty($this->getSession()
        ->getPage()
        ->getContent(), $this->baseUri, $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 = [
        'type' => 'uri',
        'value' => $this->nodeUri,
    ];
    $this->assertTrue($this->hasRdfProperty($this->getSession()
        ->getPage()
        ->getContent(), $this->baseUri, $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 = [
        'type' => 'uri',
        'value' => $comment_1_uri,
    ];
    $this->assertTrue($this->hasRdfProperty($this->getSession()
        ->getPage()
        ->getContent(), $this->baseUri, $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).');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.