Skip to content
This repository
Browse code

_suppressEolIssues becomes _normalizeLineEndings and returns array

  • Loading branch information...
commit b338b7fcdba5ef60549528b541136ffbbf6c9ad6 1 parent de9949e
Hans Donner hans-d authored

Showing 1 changed file with 9 additions and 9 deletions. Show diff stats Hide diff stats

  1. +9 9 test/Unit.php
18 test/Unit.php
@@ -248,12 +248,12 @@ public function fail($message = false) {
248 248 * in assertEqual, assertNotEqual, assertPattern and assertNotPattern this function is
249 249 * called to get rid of any EOL differences.
250 250 */
251   - protected function _suppressEolIssues(&$expected, &$result) {
252   - if (!is_string($expected) && !is_string($result)) {
253   - continue;
  251 + protected function _normalizeLineEndings($expected, $result) {
  252 + if (is_string($expected) && is_string($result)) {
  253 + $expected = preg_replace('/\r\n/', "\n", $expected);
  254 + $result = preg_replace('/\r\n/', "\n", $result);
254 255 }
255   - $expected = preg_replace('/\r\n/', "\n", $expected);
256   - $result = preg_replace('/\r\n/', "\n", $result);
  256 + return array($expected, $result);
257 257 }
258 258
259 259 /**
@@ -265,7 +265,7 @@ protected function _suppressEolIssues(&$expected, &$result) {
265 265 * @param string|boolean $message
266 266 */
267 267 public function assertEqual($expected, $result, $message = false) {
268   - $this->_suppressEolIssues($expected, $result);
  268 + list($expected, $result) = $this->_normalizeLineEndings($expected, $result);
269 269 $data = ($expected != $result) ? $this->_compare('equal', $expected, $result) : null;
270 270 $this->assert($expected == $result, $message, $data);
271 271 }
@@ -278,7 +278,7 @@ public function assertEqual($expected, $result, $message = false) {
278 278 * @param string|boolean $message
279 279 */
280 280 public function assertNotEqual($expected, $result, $message = false) {
281   - $this->_suppressEolIssues($expected, $result);
  281 + list($expected, $result) = $this->_normalizeLineEndings($expected, $result);
282 282 $this->assert($result != $expected, $message, compact('expected', 'result'));
283 283 }
284 284
@@ -361,7 +361,7 @@ public function assertNull($result, $message = '{:message}') {
361 361 * @param string $message
362 362 */
363 363 public function assertNoPattern($expected, $result, $message = '{:message}') {
364   - $this->_suppressEolIssues($expected, $result);
  364 + list($expected, $result) = $this->_normalizeLineEndings($expected, $result);
365 365 $this->assert(!preg_match($expected, $result), $message, compact('expected', 'result'));
366 366 }
367 367
@@ -373,7 +373,7 @@ public function assertNoPattern($expected, $result, $message = '{:message}') {
373 373 * @param string $message
374 374 */
375 375 public function assertPattern($expected, $result, $message = '{:message}') {
376   - $this->_suppressEolIssues($expected, $result);
  376 + list($expected, $result) = $this->_normalizeLineEndings($expected, $result);
377 377 $this->assert(!!preg_match($expected, $result), $message, compact('expected', 'result'));
378 378 }
379 379

0 comments on commit b338b7f

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