guzzle / psr7

PSR-7 HTTP message library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tests fail on Windows if git is configured with `core.autocrlf=true`

kallesommernielsen opened this issue · comments

PHP version:
Irrelevant

Description
If a checkout is performed with the core.autocrlf Git config option set to true, then some flaky tests will fail

How to reproduce

git config --system core.autoclf true
git clone ...
cd psr7
composer install
call vendor/bin/phpunit

Possible Solution
Hardcode the specific line endings without using nowdocs and drop the then redundant \str_replace() calls

Additional context

PHPUnit 9.5.10 by Sebastian Bergmann and contributors.

Warning:       Your XML configuration validates against a deprecated schema.
Suggestion:    Migrate your XML configuration using "--migrate-configuration"!

...........S...........................S.......................  63 / 898 (  7%)
..........................................FFF........S......... 126 / 898 ( 14%)
............................................................... 189 / 898 ( 21%)
............................................................... 252 / 898 ( 28%)
.......................................S....................... 315 / 898 ( 35%)
............................................................... 378 / 898 ( 42%)
............................................................... 441 / 898 ( 49%)
............................................................... 504 / 898 ( 56%)
............................................................... 567 / 898 ( 63%)
............................................................... 630 / 898 ( 70%)
............................................................... 693 / 898 ( 77%)
............................................................... 756 / 898 ( 84%)
............................................................... 819 / 898 ( 91%)
............................S.................................. 882 / 898 ( 98%)
................                                                898 / 898 (100%)

Time: 00:00.568, Memory: 16.00 MB

There were 3 failures:

1) GuzzleHttp\Tests\Psr7\MultipartStreamTest::testSerializesFiles
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 #Warning: Strings contain different line endings!
-'--boundary
-Content-Disposition: form-data; name="foo"; filename="bar.txt"
-Content-Length: 3
-Content-Type: text/plain
-
-foo
---boundary
-Content-Disposition: form-data; name="qux"; filename="baz.jpg"
-Content-Length: 3
-Content-Type: image/jpeg
-
-baz
---boundary
-Content-Disposition: form-data; name="qux"; filename="bar.gif"
-Content-Length: 3
-Content-Type: image/gif
-
-bar
---boundary--
+'--boundary
+Content-Disposition: form-data; name="foo"; filename="bar.txt"
+Content-Length: 3
+Content-Type: text/plain
+
+foo
+--boundary
+Content-Disposition: form-data; name="qux"; filename="baz.jpg"
+Content-Length: 3
+Content-Type: image/jpeg
+
+baz
+--boundary
+Content-Disposition: form-data; name="qux"; filename="bar.gif"
+Content-Length: 3
+Content-Type: image/gif
+
+bar
+--boundary--
 '

F:\dev\foss\psr7\tests\MultipartStreamTest.php:159

2) GuzzleHttp\Tests\Psr7\MultipartStreamTest::testSerializesFilesWithCustomHeaders
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 #Warning: Strings contain different line endings!
-'--boundary
-x-foo: bar
-content-disposition: custom
-Content-Length: 3
-Content-Type: text/plain
-
-foo
---boundary--
+'--boundary
+x-foo: bar
+content-disposition: custom
+Content-Length: 3
+Content-Type: text/plain
+
+foo
+--boundary--
 '

F:\dev\foss\psr7\tests\MultipartStreamTest.php:193

3) GuzzleHttp\Tests\Psr7\MultipartStreamTest::testSerializesFilesWithCustomHeadersAndMultipleValues
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 #Warning: Strings contain different line endings!
-'--boundary
-x-foo: bar
-content-disposition: custom
-Content-Length: 3
-Content-Type: text/plain
-
-foo
---boundary
-cOntenT-Type: custom
-Content-Disposition: form-data; name="foo"; filename="baz.jpg"
-Content-Length: 3
-
-baz
---boundary--
+'--boundary
+x-foo: bar
+content-disposition: custom
+Content-Length: 3
+Content-Type: text/plain
+
+foo
+--boundary
+cOntenT-Type: custom
+Content-Disposition: form-data; name="foo"; filename="baz.jpg"
+Content-Length: 3
+
+baz
+--boundary--
 '

F:\dev\foss\psr7\tests\MultipartStreamTest.php:244

FAILURES!
Tests: 898, Assertions: 2043, Failures: 3, Skipped: 5.