You are here

protected function StandardProfileTest::doFrontPageRdfaTests in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/rdf/src/Tests/StandardProfileTest.php \Drupal\rdf\Tests\StandardProfileTest::doFrontPageRdfaTests()

Tests that data is exposed in the front page teasers.

1 call to StandardProfileTest::doFrontPageRdfaTests()
StandardProfileTest::testRdfaOutput in core/modules/rdf/src/Tests/StandardProfileTest.php
Tests that data is exposed correctly when using standard profile.

File

core/modules/rdf/src/Tests/StandardProfileTest.php, line 208
Contains \Drupal\rdf\Tests\StandardProfileTest.

Class

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

Namespace

Drupal\rdf\Tests

Code

protected function doFrontPageRdfaTests() {

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

  // Ensure that both articles are listed.
  $this
    ->assertEqual(2, count($graph
    ->allOfType('http://schema.org/Article')), 'Two articles found on front page.');

  // Test interaction count.
  $expected_value = array(
    'type' => 'literal',
    'value' => 'UserComments:1',
    'lang' => 'en',
  );
  $this
    ->assertTrue($graph
    ->hasProperty($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($graph, $this->article, "Teaser");

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

  // @todo Once the image points to the original instead of the processed
  //   image, move this to testArticleProperties().
  $image_file = $this->article
    ->get('field_image')->entity;
  $image_uri = ImageStyle::load('medium')
    ->buildUrl($image_file
    ->getFileUri());
  $expected_value = array(
    'type' => 'uri',
    'value' => $image_uri,
  );
  $this
    ->assertTrue($graph
    ->hasProperty($this->articleUri, 'http://schema.org/image', $expected_value), "Teaser image was found (schema:image).");
}