#933856 by Damien Tournoud: Fixed xpath() return values are inconsistent, leading to failing tests on some environments.
parent
fc8be9eeb4
commit
6539970db4
|
@ -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]");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue