Skip to content
Browse files

simplify test for strings on _suppressEolIssues

  • Loading branch information...
1 parent b760352 commit de9949e26bead7496be1f5e71234bcb2eb48430a @hans-d hans-d committed May 23, 2012
Showing with 9 additions and 14 deletions.
  1. +9 −14 test/Unit.php
View
23 test/Unit.php
@@ -249,8 +249,11 @@ public function fail($message = false) {
* called to get rid of any EOL differences.
*/
protected function _suppressEolIssues(&$expected, &$result) {
- $expected = preg_replace('/\r\n/', "\n", $expected);
- $result = preg_replace('/\r\n/', "\n", $result);
+ if (!is_string($expected) && !is_string($result)) {
+ continue;
+ }
+ $expected = preg_replace('/\r\n/', "\n", $expected);
+ $result = preg_replace('/\r\n/', "\n", $result);
}
/**
@@ -262,9 +265,7 @@ protected function _suppressEolIssues(&$expected, &$result) {
* @param string|boolean $message
*/
public function assertEqual($expected, $result, $message = false) {
- if (is_string($expected) && is_string($result)) {
- $this->_suppressEolIssues($expected, $result);
- }
+ $this->_suppressEolIssues($expected, $result);
$data = ($expected != $result) ? $this->_compare('equal', $expected, $result) : null;
$this->assert($expected == $result, $message, $data);
}
@@ -277,9 +278,7 @@ public function assertEqual($expected, $result, $message = false) {
* @param string|boolean $message
*/
public function assertNotEqual($expected, $result, $message = false) {
- if (is_string($expected) && is_string($result)) {
- $this->_suppressEolIssues($expected, $result);
- }
+ $this->_suppressEolIssues($expected, $result);
$this->assert($result != $expected, $message, compact('expected', 'result'));
}
@@ -362,9 +361,7 @@ public function assertNull($result, $message = '{:message}') {
* @param string $message
*/
public function assertNoPattern($expected, $result, $message = '{:message}') {
- if (is_string($expected) && is_string($result)) {
- $this->_suppressEolIssues($expected, $result);
- }
+ $this->_suppressEolIssues($expected, $result);
$this->assert(!preg_match($expected, $result), $message, compact('expected', 'result'));
}
@@ -376,9 +373,7 @@ public function assertNoPattern($expected, $result, $message = '{:message}') {
* @param string $message
*/
public function assertPattern($expected, $result, $message = '{:message}') {
- if (is_string($expected) && is_string($result)) {
- $this->_suppressEolIssues($expected, $result);
- }
+ $this->_suppressEolIssues($expected, $result);
$this->assert(!!preg_match($expected, $result), $message, compact('expected', 'result'));
}

0 comments on commit de9949e

Please sign in to comment.
Something went wrong with that request. Please try again.