You are here

public function CommentAttributesTest::testNumberOfCommentsRdfaMarkup in Zircon Profile 8.0

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

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

File

core/modules/rdf/src/Tests/CommentAttributesTest.php, line 121
Contains \Drupal\rdf\Tests\CommentAttributesTest.

Class

CommentAttributesTest
Tests the RDFa markup of comments.

Namespace

Drupal\rdf\Tests

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);
  $parser = new \EasyRdf_Parser_Rdfa();
  $graph = new \EasyRdf_Graph();
  $parser
    ->parse($graph, $this
    ->drupalGet('node'), 'rdfa', $this->baseUri);

  // Number of comments.
  $expected_value = array(
    'type' => 'literal',
    'value' => 2,
    'datatype' => 'http://www.w3.org/2001/XMLSchema#integer',
  );
  $this
    ->assertTrue($graph
    ->hasProperty($this->nodeUri, 'http://rdfs.org/sioc/ns#num_replies', $expected_value), 'Number of comments found in RDF output of teaser view (sioc:num_replies).');

  // Tests number of comments in full node view, expected value is the same.
  $parser = new \EasyRdf_Parser_Rdfa();
  $graph = new \EasyRdf_Graph();
  $parser
    ->parse($graph, $this
    ->drupalGet('node/' . $this->node
    ->id()), 'rdfa', $this->baseUri);
  $this
    ->assertTrue($graph
    ->hasProperty($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).');
}