You are here

public function CommentAttributesTest::testCommentRdfaMarkup in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/rdf/src/Tests/CommentAttributesTest.php \Drupal\rdf\Tests\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

core/modules/rdf/src/Tests/CommentAttributesTest.php, line 171
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
    ->id(), $this->webUser
    ->id());

  // Tests comment #1 with access to the user profile.
  $this
    ->drupalLogin($this->webUser);
  $parser = new \EasyRdf_Parser_Rdfa();
  $graph = new \EasyRdf_Graph();
  $parser
    ->parse($graph, $this
    ->drupalGet('node/' . $this->node
    ->id()), 'rdfa', $this->baseUri);
  $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
    ->id()), 'rdfa', $this->baseUri);
  $this
    ->_testBasicCommentRdfaMarkup($graph, $comment1);

  // Posts comment #2 as anonymous user.
  $anonymous_user = array();
  $anonymous_user['name'] = $this
    ->randomMachineName();
  $anonymous_user['mail'] = 'tester@simpletest.org';
  $anonymous_user['homepage'] = 'http://example.org/';
  $comment2 = $this
    ->saveComment($this->node
    ->id(), 0, $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
    ->id()), 'rdfa', $this->baseUri);
  $this
    ->_testBasicCommentRdfaMarkup($graph, $comment2, $anonymous_user);

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