You are here

public function CommentAttributesTest::testCommentRdfaMarkup in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/rdf/tests/src/Functional/CommentAttributesTest.php \Drupal\Tests\rdf\Functional\CommentAttributesTest::testCommentRdfaMarkup()
  2. 9 core/modules/rdf/tests/src/Functional/CommentAttributesTest.php \Drupal\Tests\rdf\Functional\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/tests/src/Functional/CommentAttributesTest.php, line 181

Class

CommentAttributesTest
Tests the RDFa markup of comments.

Namespace

Drupal\Tests\rdf\Functional

Code

public function testCommentRdfaMarkup() {

  // Set to test the altered display name.
  \Drupal::state()
    ->set('user_hooks_test_user_format_name_alter', TRUE);

  // 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);
  $this
    ->_testBasicCommentRdfaMarkup($comment1);

  // Tests comment #1 with no access to the user profile (as anonymous user).
  $this
    ->drupalLogout();
  $this
    ->_testBasicCommentRdfaMarkup($comment1);

  // Posts comment #2 as anonymous user.
  $anonymous_user = [];
  $anonymous_user['name'] = $this
    ->randomMachineName();
  $anonymous_user['mail'] = 'test@example.org';
  $anonymous_user['homepage'] = 'http://example.org/';
  $comment2 = $this
    ->saveComment($this->node
    ->id(), 0, $anonymous_user);
  $anonymous = User::load(0);

  // Tests comment #2 as anonymous user.
  $this
    ->_testBasicCommentRdfaMarkup($comment2, $anonymous);

  // Tests comment #2 as logged in user.
  $this
    ->drupalLogin($this->webUser);
  $this
    ->_testBasicCommentRdfaMarkup($comment2, $anonymous);
}