function CommentAttributesTest::_testBasicCommentRdfaMarkup

Helper function for testCommentRdfaMarkup().

Tests the current page for basic comment RDFa markup.

Parameters

$comment: Comment object.

$account: An array containing information about an anonymous user.

1 call to CommentAttributesTest::_testBasicCommentRdfaMarkup()
CommentAttributesTest::testCommentRdfaMarkup in drupal/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php
Tests if RDFa markup for meta information is present in comments.

File

drupal/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php, line 180
Definition of Drupal\rdf\Tests\CommentAttributesTest.

Class

CommentAttributesTest
Tests the RDFa markup of comments.

Namespace

Drupal\rdf\Tests

Code

function _testBasicCommentRdfaMarkup($comment, $account = array()) {
  $comment_container = $this
    ->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]');
  $this
    ->assertTrue(!empty($comment_container), 'Comment RDF type for comment found.');
  $comment_title = $this
    ->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//h3[@property="dc:title"]');
  $this
    ->assertEqual((string) $comment_title[0]->a, $comment->subject, 'RDFa markup for the comment title found.');
  $comment_date = $this
    ->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//*[contains(@property, "dc:date") and contains(@property, "dc:created")]');
  $this
    ->assertTrue(!empty($comment_date), 'RDFa markup for the date of the comment found.');

  // The author tag can be either a or span
  $comment_author = $this
    ->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//span[@rel="sioc:has_creator"]/*[contains(@class, "username") and @typeof="sioc:UserAccount" and @property="foaf:name"]');
  $name = empty($account["name"]) ? $this->web_user->name : $account["name"] . " (not verified)";
  $this
    ->assertEqual((string) $comment_author[0], $name, 'RDFa markup for the comment author found.');
  $comment_body = $this
    ->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//div[@class="content"]//div[contains(@class, "comment-body")]//div[@property="content:encoded"]');
  $this
    ->assertEqual((string) $comment_body[0]->p, $comment->comment, 'RDFa markup for the comment body found.');
}