protected function StandardProfileTest::assertRdfaNodeCommentProperties in Drupal 10
Same name and namespace in other branches
- 8 core/modules/rdf/tests/src/Functional/StandardProfileTest.php \Drupal\Tests\rdf\Functional\StandardProfileTest::assertRdfaNodeCommentProperties()
- 9 core/modules/rdf/tests/src/Functional/StandardProfileTest.php \Drupal\Tests\rdf\Functional\StandardProfileTest::assertRdfaNodeCommentProperties()
Tests output for comment properties on nodes in full page view mode.
@internal
File
- core/
modules/ rdf/ tests/ src/ Functional/ StandardProfileTest.php, line 465
Class
- StandardProfileTest
- Tests the RDF mappings and RDFa markup on top of the standard profile.
Namespace
Drupal\Tests\rdf\FunctionalCode
protected function assertRdfaNodeCommentProperties() : void {
$this
->drupalGet($this->article
->toUrl());
// Relationship between node and comment.
$expected_value = [
'type' => 'uri',
'value' => $this->articleCommentUri,
];
$this
->assertTrue($this
->hasRdfProperty($this
->getSession()
->getPage()
->getContent(), $this->baseUri, $this->articleUri, 'http://schema.org/comment', $expected_value), "Relationship between node and comment found (schema:comment).");
// Comment type.
$this
->assertEquals('schema:Comment', $this
->getElementRdfType($this->article
->toUrl(), $this->baseUri, $this->articleCommentUri), 'Comment type was found (schema:Comment).');
// Comment title.
$expected_value = [
'type' => 'literal',
'value' => $this->articleComment
->get('subject')->value,
'lang' => 'en',
];
$this
->assertTrue($this
->hasRdfProperty($this
->getSession()
->getPage()
->getContent(), $this->baseUri, $this->articleCommentUri, 'http://schema.org/name', $expected_value), "Article comment title was found (schema:name).");
// Comment created date.
$expected_value = [
'type' => 'literal',
'value' => $this->container
->get('date.formatter')
->format($this->articleComment
->get('created')->value, 'custom', 'c', 'UTC'),
'lang' => 'en',
];
$this
->assertTrue($this
->hasRdfProperty($this
->getSession()
->getPage()
->getContent(), $this->baseUri, $this->articleCommentUri, 'http://schema.org/dateCreated', $expected_value), "Article comment created date was found (schema:dateCreated).");
// Comment body.
$text = $this->articleComment
->get('comment_body')->value;
$expected_value = [
'type' => 'literal',
// There is an extra carriage return in the value when parsing comments as
// output by Bartik, so it must be added to the expected value.
'value' => "{$text}\n",
'lang' => 'en',
];
$this
->assertTrue($this
->hasRdfProperty($this
->getSession()
->getPage()
->getContent(), $this->baseUri, $this->articleCommentUri, 'http://schema.org/text', $expected_value), "Article comment body was found (schema:text).");
// Comment uid.
$expected_value = [
'type' => 'uri',
'value' => $this->commenterUri,
];
$this
->assertTrue($this
->hasRdfProperty($this
->getSession()
->getPage()
->getContent(), $this->baseUri, $this->articleCommentUri, 'http://schema.org/author', $expected_value), "Article comment author was found (schema:author).");
// Comment author type.
$this
->assertEquals('schema:Person', $this
->getElementRdfType($this->article
->toUrl(), $this->baseUri, $this->commenterUri), 'Comment author type was found (schema:Person).');
// Comment author name.
$expected_value = [
'type' => 'literal',
'value' => $this->webUser
->getAccountName(),
];
$this
->assertTrue($this
->hasRdfProperty($this
->getSession()
->getPage()
->getContent(), $this->baseUri, $this->commenterUri, 'http://schema.org/name', $expected_value), "Comment author name was found (schema:name).");
}