function CommentAttributesTest::testNumberOfCommentsRdfaMarkup

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

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

File

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

Class

CommentAttributesTest
Tests the RDFa markup of comments.

Namespace

Drupal\Tests\rdf\Functional

Code

public function testNumberOfCommentsRdfaMarkup() {
  // Posts 2 comments on behalf of registered user.
  $this->saveComment($this->node
    ->id(), $this->webUser
    ->id());
  $this->saveComment($this->node
    ->id(), $this->webUser
    ->id());
  // Tests number of comments in teaser view.
  $this->drupalLogin($this->webUser);
  $this->drupalGet('node');
  // Number of comments.
  $expected_value = [
    'type' => 'literal',
    'value' => 2,
    'datatype' => 'http://www.w3.org/2001/XMLSchema#integer',
  ];
  $this->assertTrue($this->hasRdfProperty($this->getSession()
    ->getPage()
    ->getContent(), $this->baseUri, $this->nodeUri, 'http://rdfs.org/sioc/ns#num_replies', $expected_value), 'Number of comments found in RDF output of teaser view (sioc:num_replies).');
  $this->drupalGet($this->node
    ->toUrl());
  $this->assertTrue($this->hasRdfProperty($this->getSession()
    ->getPage()
    ->getContent(), $this->baseUri, $this->nodeUri, 'http://rdfs.org/sioc/ns#num_replies', $expected_value), 'Number of comments found in RDF output of full node view mode (sioc:num_replies).');
}

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