public function CommentAttributesTest::testCommentRdfaMarkup

Tests if RDFa markup for meta information is present in comments.

Tests presence of RDFa markup for the title, date and author and homepage on comments from registered and anonymous users.

File

drupal/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php, line 91
Contains Drupal\rdf\Tests\CommentAttributesTest.

Class

CommentAttributesTest
Tests the RDFa markup of comments.

Namespace

Drupal\rdf\Tests

Code

public function testCommentRdfaMarkup() {

  // Posts comment #1 on behalf of registered user.
  $comment1 = $this
    ->saveComment($this->node->nid, $this->web_user->uid);

  // Tests comment #1 with access to the user profile.
  $this
    ->drupalLogin($this->web_user);
  $parser = new \EasyRdf_Parser_Rdfa();
  $graph = new \EasyRdf_Graph();
  $parser
    ->parse($graph, $this
    ->drupalGet('node/' . $this->node->nid), 'rdfa', $this->base_uri);
  $this
    ->_testBasicCommentRdfaMarkup($graph, $comment1);

  // Tests comment #1 with no access to the user profile (as anonymous user).
  $this
    ->drupalLogout();
  $parser = new \EasyRdf_Parser_Rdfa();
  $graph = new \EasyRdf_Graph();
  $parser
    ->parse($graph, $this
    ->drupalGet('node/' . $this->node->nid), 'rdfa', $this->base_uri);
  $this
    ->_testBasicCommentRdfaMarkup($graph, $comment1);

  // Posts comment #2 as anonymous user.
  $anonymous_user = array();
  $anonymous_user['name'] = $this
    ->randomName();
  $anonymous_user['mail'] = 'tester@simpletest.org';
  $anonymous_user['homepage'] = 'http://example.org/';
  $comment2 = $this
    ->saveComment($this->node->nid, NULL, $anonymous_user);

  // Tests comment #2 as anonymous user.
  $parser = new \EasyRdf_Parser_Rdfa();
  $graph = new \EasyRdf_Graph();
  $parser
    ->parse($graph, $this
    ->drupalGet('node/' . $this->node->nid), 'rdfa', $this->base_uri);
  $this
    ->_testBasicCommentRdfaMarkup($graph, $comment2, $anonymous_user);

  // Tests comment #2 as logged in user.
  $this
    ->drupalLogin($this->web_user);
  $parser = new \EasyRdf_Parser_Rdfa();
  $graph = new \EasyRdf_Graph();
  $parser
    ->parse($graph, $this
    ->drupalGet('node/' . $this->node->nid), 'rdfa', $this->base_uri);
  $this
    ->_testBasicCommentRdfaMarkup($graph, $comment2, $anonymous_user);
}