public function CommentAttributesTest::testNumberOfCommentsRdfaMarkup in Drupal 9
Same name and namespace in other branches
- 8 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 133
Class
- CommentAttributesTest
- Tests the RDFa markup of comments.
Namespace
Drupal\Tests\rdf\FunctionalCode
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).');
}