/** * Helper function for testCommentRdfaMarkup(). * * Tests the current page for basic comment RDFa markup. * * @param $comment * Comment object. * @param $account * An array containing information about an anonymous user. */ function _testBasicCommentRdfaMarkup($graph, CommentInterface $comment, $account = array()) { $comment_uri = $comment->url('canonical', array('absolute' => TRUE)); // Comment type. $expected_value = array('type' => 'uri', 'value' => 'http://rdfs.org/sioc/types#Comment'); $this->assertTrue($graph->hasProperty($comment_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Comment type found in RDF output (sioct:Comment).'); // Comment type. $expected_value = array('type' => 'uri', 'value' => 'http://rdfs.org/sioc/ns#Post'); $this->assertTrue($graph->hasProperty($comment_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Comment type found in RDF output (sioc:Post).'); // Comment title. $expected_value = array('type' => 'literal', 'value' => $comment->getSubject(), 'lang' => 'en'); $this->assertTrue($graph->hasProperty($comment_uri, 'http://purl.org/dc/terms/title', $expected_value), 'Comment subject found in RDF output (dc:title).'); // Comment date. $expected_value = array('type' => 'literal', 'value' => date('c', $comment->getCreatedTime()), 'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime'); $this->assertTrue($graph->hasProperty($comment_uri, 'http://purl.org/dc/terms/date', $expected_value), 'Comment date found in RDF output (dc:date).'); // Comment date. $expected_value = array('type' => 'literal', 'value' => date('c', $comment->getCreatedTime()), 'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime'); $this->assertTrue($graph->hasProperty($comment_uri, 'http://purl.org/dc/terms/created', $expected_value), 'Comment date found in RDF output (dc:created).'); // Comment body. $expected_value = array('type' => 'literal', 'value' => $comment->comment_body->value . "\n", 'lang' => 'en'); $this->assertTrue($graph->hasProperty($comment_uri, 'http://purl.org/rss/1.0/modules/content/encoded', $expected_value), 'Comment body found in RDF output (content:encoded).'); // The comment author can be a registered user or an anonymous user. if ($comment->getOwnerId() > 0) { $author_uri = url('user/' . $comment->getOwnerId(), array('absolute' => TRUE)); // Comment relation to author. $expected_value = array('type' => 'uri', 'value' => $author_uri); $this->assertTrue($graph->hasProperty($comment_uri, 'http://rdfs.org/sioc/ns#has_creator', $expected_value), 'Comment relation to author found in RDF output (sioc:has_creator).'); } else { // The author is expected to be a blank node. $author_uri = $graph->get($comment_uri, '<http://rdfs.org/sioc/ns#has_creator>'); if ($author_uri instanceof \EasyRdf_Resource) { $this->assertTrue($author_uri->isBnode(), 'Comment relation to author found in RDF output (sioc:has_creator) and author is blank node.'); } else { $this->fail('Comment relation to author found in RDF output (sioc:has_creator).'); } } // Author name. $name = empty($account["name"]) ? $this->web_user->getUsername() : $account["name"] . " (not verified)"; $expected_value = array('type' => 'literal', 'value' => $name); $this->assertTrue($graph->hasProperty($author_uri, 'http://xmlns.com/foaf/0.1/name', $expected_value), 'Comment author name found in RDF output (foaf:name).'); // Comment author homepage (only for anonymous authors). if ($comment->getOwnerId() == 0) { $expected_value = array('type' => 'uri', 'value' => 'http://example.org/'); $this->assertTrue($graph->hasProperty($author_uri, 'http://xmlns.com/foaf/0.1/page', $expected_value), 'Comment author link found in RDF output (foaf:page).'); } }