Commit 8c7fd11f authored by Dries's avatar Dries

- Patch #419114 by boombatower: clean up assertions.

parent c5926f49
...@@ -1672,7 +1672,10 @@ protected function drupalSetContent($content, $url = 'internal:') { ...@@ -1672,7 +1672,10 @@ protected function drupalSetContent($content, $url = 'internal:') {
* @return * @return
* TRUE on pass, FALSE on fail. * TRUE on pass, FALSE on fail.
*/ */
protected function assertRaw($raw, $message = '%s found', $group = 'Other') { protected function assertRaw($raw, $message = '', $group = 'Other') {
if (!$message) {
$message = t('Raw "@raw" found', array('@raw' => check_plain($raw)));
}
return $this->assert(strpos($this->content, $raw) !== FALSE, $message, $group); return $this->assert(strpos($this->content, $raw) !== FALSE, $message, $group);
} }
...@@ -1689,7 +1692,10 @@ protected function assertRaw($raw, $message = '%s found', $group = 'Other') { ...@@ -1689,7 +1692,10 @@ protected function assertRaw($raw, $message = '%s found', $group = 'Other') {
* @return * @return
* TRUE on pass, FALSE on fail. * TRUE on pass, FALSE on fail.
*/ */
protected function assertNoRaw($raw, $message = '%s found', $group = 'Other') { protected function assertNoRaw($raw, $message = '', $group = 'Other') {
if (!$message) {
$message = t('Raw "@raw" not found', array('@raw' => check_plain($raw)));
}
return $this->assert(strpos($this->content, $raw) === FALSE, $message, $group); return $this->assert(strpos($this->content, $raw) === FALSE, $message, $group);
} }
...@@ -1750,7 +1756,7 @@ protected function assertTextHelper($text, $message, $group, $not_exists) { ...@@ -1750,7 +1756,7 @@ protected function assertTextHelper($text, $message, $group, $not_exists) {
$this->plainTextContent = filter_xss($this->content, array()); $this->plainTextContent = filter_xss($this->content, array());
} }
if (!$message) { if (!$message) {
$message = '"' . $text . '"' . ($not_exists ? ' not found' : ' found'); $message = !$not_exists ? t('"@text" found', array('@text' => $text)) : t('"@text" not found', array('@text' => $text));
} }
return $this->assert($not_exists == (strpos($this->plainTextContent, $text) === FALSE), $message, $group); return $this->assert($not_exists == (strpos($this->plainTextContent, $text) === FALSE), $message, $group);
} }
...@@ -1839,7 +1845,10 @@ protected function assertUniqueTextHelper($text, $message, $group, $be_unique) { ...@@ -1839,7 +1845,10 @@ protected function assertUniqueTextHelper($text, $message, $group, $be_unique) {
* @return * @return
* TRUE on pass, FALSE on fail. * TRUE on pass, FALSE on fail.
*/ */
protected function assertPattern($pattern, $message = 'Pattern %s found', $group = 'Other') { protected function assertPattern($pattern, $message = '', $group = 'Other') {
if (!$message) {
$message = t('Pattern "@pattern" found', array('@pattern' => $pattern));
}
return $this->assert((bool) preg_match($pattern, $this->drupalGetContent()), $message, $group); return $this->assert((bool) preg_match($pattern, $this->drupalGetContent()), $message, $group);
} }
...@@ -1855,7 +1864,10 @@ protected function assertPattern($pattern, $message = 'Pattern %s found', $group ...@@ -1855,7 +1864,10 @@ protected function assertPattern($pattern, $message = 'Pattern %s found', $group
* @return * @return
* TRUE on pass, FALSE on fail. * TRUE on pass, FALSE on fail.
*/ */
protected function assertNoPattern($pattern, $message = 'Pattern %s not found', $group = 'Other') { protected function assertNoPattern($pattern, $message = '', $group = 'Other') {
if (!$message) {
$message = t('Pattern "@pattern" not found', array('@pattern' => $pattern));
}
return $this->assert(!preg_match($pattern, $this->drupalGetContent()), $message, $group); return $this->assert(!preg_match($pattern, $this->drupalGetContent()), $message, $group);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment