Permalink
Browse files

Fixes #581: Windows diffs where polluted with extra newlines

  • Loading branch information...
1 parent 5f0a76f commit 6f60604d73cd6bf95408aed857fec4069b43575b @edorian edorian committed Sep 6, 2012
Showing with 55 additions and 1 deletion.
  1. +1 −0 ChangeLog.markdown
  2. +1 −1 PHPUnit/Util/Type.php
  3. +43 −0 Tests/Regression/GitHub/581.phpt
  4. +10 −0 Tests/Regression/GitHub/581/Issue581Test.php
View
@@ -28,6 +28,7 @@ PHPUnit 3.7.0
* Fixed #322 #320 thanks to #607: Commandline option now override group/exclude settings in phpunit.xml
* Fixed #440: Possible crash when using `--process-isolation` with PHP 5.3 and `detect_unicode=on`.
* Fixed #523: `assertAttributeEquals()` now works with classes extending internal classes like `ArrayIterator`.
+* Fixed #581: Generating a diffs could add extra newlines in Windows.
* It is possible again to expect the generic `Exception` class.
* Removed `addUncoveredFilesFromWhitelist` configuration setting.
* Removed deprecated `--skeleton-class` and `--skeleton-test` switches. The functionality is now provided by the `phpunit-skel` command of the `PHPUnit_SkeletonGenerator` package.
View
@@ -133,7 +133,7 @@ protected static function recursiveExport($value, $indentation, &$processedObjec
}
return "'" .
- str_replace(array("\n\r", "\r"), array("\n", "\n"), $value) .
+ str_replace(array("\r\n", "\n\r", "\r"), array("\n", "\n", "\n"), $value) .
"'";
}
@@ -0,0 +1,43 @@
+--TEST--
+GH-581: PHPUnit_Util_Type::export adds extra newlines in Windows
+--FILE--
+<?php
+
+$_SERVER['argv'][1] = '--no-configuration';
+$_SERVER['argv'][2] = 'Issue581Test';
+$_SERVER['argv'][3] = dirname(__FILE__).'/581/Issue581Test.php';
+
+require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/PHPUnit/Autoload.php';
+PHPUnit_TextUI_Command::main();
+?>
+--EXPECTF--
+PHPUnit %s by Sebastian Bergmann.
+
+F
+
+Time: %i %s, Memory: %sMb
+
+There was 1 failure:
+
+1) Issue581Test::testExportingObjectsDoesNotBreakWindowsLineFeeds
+Failed asserting that two objects are equal.
+--- Expected
++++ Actual
+@@ @@
+ stdClass Object (
+ 0 => 1
+ 1 => 2
+ 2 => 'Test\n'
+ 3 => 4
+- 4 => 5
++ 4 => 1
+ 5 => 6
+ 6 => 7
+ 7 => 8
+ )
+
+%s:%i
+
+FAILURES!
+Tests: 1, Assertions: 1, Failures: 1.
+
@@ -0,0 +1,10 @@
+<?php
+class Issue581Test extends PHPUnit_Framework_TestCase
+{
+ public function testExportingObjectsDoesNotBreakWindowsLineFeeds() {
+ $this->assertEquals(
+ (object)array(1,2,"Test\r\n",4,5,6,7,8),
+ (object)array(1,2,"Test\r\n",4,1,6,7,8)
+ );
+ }
+}

0 comments on commit 6f60604

Please sign in to comment.