diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-03-31 20:05:06 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-03-31 20:05:06 +0000 |
commit | 6fc055ab906c035355bfb789aed404551db5b45a (patch) | |
tree | f29650c65f8a7003ce73ebc6047f216f91e14c79 /modules/comment/comment.test | |
parent | e0871ec49bb81adff156d4bc7cf2d9f8b50d04a0 (diff) | |
download | brdo-6fc055ab906c035355bfb789aed404551db5b45a.tar.gz brdo-6fc055ab906c035355bfb789aed404551db5b45a.tar.bz2 |
- Patch #730220 by Berdir, aspilicious, Damien Tournoud, pwolanin: improved xpath tests.
Diffstat (limited to 'modules/comment/comment.test')
-rw-r--r-- | modules/comment/comment.test | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/modules/comment/comment.test b/modules/comment/comment.test index f9d151ea7..ab81035ff 100644 --- a/modules/comment/comment.test +++ b/modules/comment/comment.test @@ -762,7 +762,7 @@ class CommentPagerTest extends CommentHelperCase { $expected_cids[] = $comments[$key]->id; } - $comment_anchors = $this->xpath("//a[starts-with(@id,'comment-')]"); + $comment_anchors = $this->xpath('//a[starts-with(@id,"comment-")]'); $result_order = array(); foreach ($comment_anchors as $anchor) { $result_order[] = substr($anchor['id'], 8); @@ -1134,13 +1134,13 @@ class CommentRdfaTestCase extends CommentHelperCase { // Tests number of comments in teaser view. $this->drupalGet('node'); - $comment_count_teaser = $this->xpath("//div[contains(@typeof, 'sioc:Item')]//li[contains(@class, 'comment_comments')]/a[contains(@property, 'sioc:num_replies') and contains(@content, '2') and @datatype='xsd:integer']"); + $comment_count_teaser = $this->xpath('//div[contains(@typeof, "sioc:Item")]//li[contains(@class, "comment_comments")]/a[contains(@property, "sioc:num_replies") and contains(@content, "2") and @datatype="xsd:integer"]'); $this->assertTrue(!empty($comment_count_teaser), t('RDFa markup for the number of comments found on teaser view.')); // Tests number of comments in full node view. $this->drupalGet('node/' . $this->node1->nid); $node_url = url('node/' . $this->node1->nid); - $comment_count_teaser = $this->xpath("/html/head/meta[@about='$node_url' and @property='sioc:num_replies' and @content='2' and @datatype='xsd:integer']"); + $comment_count_teaser = $this->xpath('/html/head/meta[@about=:node-url and @property="sioc:num_replies" and @content="2" and @datatype="xsd:integer"]', array(':node-url' => $node_url)); $this->assertTrue(!empty($comment_count_teaser), t('RDFa markup for the number of comments found on full node view.')); } @@ -1180,10 +1180,10 @@ class CommentRdfaTestCase extends CommentHelperCase { // Tests comment #2 as anonymous user. $this->_testBasicCommentRdfaMarkup($comment2, $anonymous_user); // Tests the RDFa markup for the homepage (specific to anonymous comments). - $comment_homepage = $this->xpath("//div[contains(@class, 'comment') and contains(@typeof, 'sioct:Comment')]//span[@rel='sioc:has_creator']/a[contains(@class, 'username') and @typeof='sioc:User' and @property='foaf:name' and @href='http://example.org/' and contains(@rel, 'foaf:page')]"); + $comment_homepage = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//span[@rel="sioc:has_creator"]/a[contains(@class, "username") and @typeof="sioc:User" and @property="foaf:name" and @href="http://example.org/" and contains(@rel, "foaf:page")]'); $this->assertTrue(!empty($comment_homepage), t('RDFa markup for the homepage of anonymous user found.')); // There should be no about attribute on anonymous comments. - $comment_homepage = $this->xpath("//div[contains(@class, 'comment') and contains(@typeof, 'sioct:Comment')]//span[@rel='sioc:has_creator']/a[@about]"); + $comment_homepage = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//span[@rel="sioc:has_creator"]/a[@about]'); $this->assertTrue(empty($comment_homepage), t('No about attribute is present on anonymous user comment.')); // Tests comment #2 as logged in user. @@ -1191,11 +1191,11 @@ class CommentRdfaTestCase extends CommentHelperCase { $this->drupalGet('node/' . $this->node2->nid); $this->_testBasicCommentRdfaMarkup($comment2, $anonymous_user); // Tests the RDFa markup for the homepage (specific to anonymous comments). - $comment_homepage = $this->xpath("//div[contains(@class, 'comment') and contains(@typeof, 'sioct:Comment')]//span[@rel='sioc:has_creator']/a[contains(@class, 'username') and @typeof='sioc:User' and @property='foaf:name' and @href='http://example.org/' and contains(@rel, 'foaf:page')]"); - $this->assertTrue(!empty($comment_homepage), t('RDFa markup for the homepage of anonymous user found.')); + $comment_homepage = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//span[@rel="sioc:has_creator"]/a[contains(@class, "username") and @typeof="sioc:User" and @property="foaf:name" and @href="http://example.org/" and contains(@rel, "foaf:page")]'); + $this->assertTrue(!empty($comment_homepage), t("RDFa markup for the homepage of anonymous user found.")); // There should be no about attribute on anonymous comments. - $comment_homepage = $this->xpath("//div[contains(@class, 'comment') and contains(@typeof, 'sioct:Comment')]//span[@rel='sioc:has_creator']/a[@about]"); - $this->assertTrue(empty($comment_homepage), t('No about attribute is present on anonymous user comment.')); + $comment_homepage = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//span[@rel="sioc:has_creator"]/a[@about]'); + $this->assertTrue(empty($comment_homepage), t("No about attribute is present on anonymous user comment.")); } /** @@ -1209,18 +1209,18 @@ class CommentRdfaTestCase extends CommentHelperCase { * An array containing information about an anonymous user. */ function _testBasicCommentRdfaMarkup($comment, $account = array()) { - $comment_container = $this->xpath("//div[contains(@class, 'comment') and contains(@typeof, 'sioct:Comment')]"); - $this->assertTrue(!empty($comment_container), t('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, t('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), t('RDFa markup for the date of the comment found.')); + $comment_container = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]'); + $this->assertTrue(!empty($comment_container), t("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, t("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), t("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:User' and @property='foaf:name']"); - $name = empty($account['name']) ? $this->web_user->name : $account['name'] . ' (not verified)'; - $this->assertEqual((string)$comment_author[0], $name, t('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, t('RDFa markup for the comment body found.')); + $comment_author = $this->xpath('//div[contains(@class, "comment") and contains(@typeof, "sioct:Comment")]//span[@rel="sioc:has_creator"]/*[contains(@class, "username") and @typeof="sioc:User" and @property="foaf:name"]'); + $name = empty($account["name"]) ? $this->web_user->name : $account["name"] . " (not verified)"; + $this->assertEqual((string)$comment_author[0], $name, t("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, t("RDFa markup for the comment body found.")); } } |