You are here

protected function StandardProfileTest::doFrontPageRdfaTests in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/rdf/tests/src/Functional/StandardProfileTest.php \Drupal\Tests\rdf\Functional\StandardProfileTest::doFrontPageRdfaTests()
  2. 9 core/modules/rdf/tests/src/Functional/StandardProfileTest.php \Drupal\Tests\rdf\Functional\StandardProfileTest::doFrontPageRdfaTests()

Tests that data is exposed in the front page teasers.

File

core/modules/rdf/tests/src/Functional/StandardProfileTest.php, line 251

Class

StandardProfileTest
Tests the RDF mappings and RDFa markup on top of the standard profile.

Namespace

Drupal\Tests\rdf\Functional

Code

protected function doFrontPageRdfaTests() {

  // Feed the HTML into the parser.
  $this
    ->drupalGet(Url::fromRoute('<front>'));

  // Ensure that both articles are listed.
  $this
    ->assertEquals(2, $this
    ->getElementByRdfTypeCount(Url::fromRoute('<front>'), $this->baseUri, 'http://schema.org/Article'), 'Two articles found on front page.');

  // Test interaction count.
  $expected_value = [
    'type' => 'literal',
    'value' => 'UserComments:1',
    'lang' => 'en',
  ];
  $this
    ->assertTrue($this
    ->hasRdfProperty($this
    ->getSession()
    ->getPage()
    ->getContent(), $this->baseUri, $this->articleUri, 'http://schema.org/interactionCount', $expected_value), 'Teaser comment count was found (schema:interactionCount).');

  // Test the properties that are common between pages and articles and are
  // displayed in full and teaser mode.
  $this
    ->assertRdfaCommonNodeProperties($this->article, "Teaser");

  // Test properties that are displayed in both teaser and full mode.
  $this
    ->assertRdfaArticleProperties("Teaser");

  // @todo Once the image points to the original instead of the processed
  //   image, move this to testArticleProperties().
  $expected_value = [
    'type' => 'uri',
    'value' => $this->imageUri,
  ];
  $this
    ->assertTrue($this
    ->hasRdfProperty($this
    ->getSession()
    ->getPage()
    ->getContent(), $this->baseUri, $this->articleUri, 'http://schema.org/image', $expected_value), 'Teaser image was found (schema:image).');
}