summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/rdf/rdf.test9
-rw-r--r--modules/simpletest/drupal_web_test_case.php6
2 files changed, 10 insertions, 5 deletions
diff --git a/modules/rdf/rdf.test b/modules/rdf/rdf.test
index 4cab590ac..5ba2e37a6 100644
--- a/modules/rdf/rdf.test
+++ b/modules/rdf/rdf.test
@@ -511,9 +511,9 @@ class RdfCommentAttributesTestCase extends CommentHelperCase {
$comments[] = $this->postComment($this->node1, $this->randomName(), $this->randomName());
// Tests the reply_of relationship of a first level comment.
- $result = $this->xpath("id('comments')//div[@class='comment' and position()=0]//span[@rel='sioc:reply_of' and @resource=:node]", array(':node' => url("node/{$this->node1->nid}")));
+ $result = $this->xpath("(id('comments')//div[contains(@class,'comment ')])[position()=1]//span[@rel='sioc:reply_of' and @resource=:node]", array(':node' => url("node/{$this->node1->nid}")));
$this->assertEqual(1, count($result), t('RDFa markup referring to the node is present.'));
- $result = $this->xpath("id('comments')//div[@class='comment' and position()=0]//span[@rel='sioc:reply_of' and @resource=:comment]", array(':comment' => url('comment/1#comment-1')));
+ $result = $this->xpath("(id('comments')//div[contains(@class,'comment ')])[position()=1]//span[@rel='sioc:reply_of' and @resource=:comment]", array(':comment' => url('comment/1#comment-1')));
$this->assertFalse($result, t('No RDFa markup referring to the comment itself is present.'));
// Posts a reply to the first comment.
@@ -521,10 +521,11 @@ class RdfCommentAttributesTestCase extends CommentHelperCase {
$comments[] = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
// Tests the reply_of relationship of a second level comment.
- $result = $this->xpath("id('comments')//div[@class='comment' and position()=1]//span[@rel='sioc:reply_of' and @resource=:node]", array(':node' => url("node/{$this->node1->nid}")));
+ $result = $this->xpath("(id('comments')//div[contains(@class,'comment ')])[position()=2]//span[@rel='sioc:reply_of' and @resource=:node]", array(':node' => url("node/{$this->node1->nid}")));
$this->assertEqual(1, count($result), t('RDFa markup referring to the node is present.'));
- $result = $this->xpath("id('comments')//div[@class='comment' and position()=1]//span[@rel='sioc:reply_of' and @resource=:comment]", array(':comment' => url('comment/1#comment-1')));
+ $result = $this->xpath("(id('comments')//div[contains(@class,'comment ')])[position()=2]//span[@rel='sioc:reply_of' and @resource=:comment]", array(':comment' => url('comment/1', array('fragment' => 'comment-1'))));
$this->assertEqual(1, count($result), t('RDFa markup referring to the parent comment is present.'));
+ $comments = $this->xpath("(id('comments')//div[contains(@class,'comment ')])[position()=2]");
}
/**
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
index ecdff06ff..1949b99a5 100644
--- a/modules/simpletest/drupal_web_test_case.php
+++ b/modules/simpletest/drupal_web_test_case.php
@@ -2188,7 +2188,11 @@ class DrupalWebTestCase extends DrupalTestCase {
protected function xpath($xpath, array $arguments = array()) {
if ($this->parse()) {
$xpath = $this->buildXPathQuery($xpath, $arguments);
- return $this->elements->xpath($xpath);
+ $result = $this->elements->xpath($xpath);
+ // Some combinations of PHP / libxml versions return an empty array
+ // instead of the documented FALSE. Forcefully convert any falsish values
+ // to an empty array to allow foreach(...) constructions.
+ return $result ? $result : array();
}
else {
return FALSE;