diff --git a/tests/Client/RequestTest.php b/tests/Client/RequestTest.php index 32430a2..1d6accd 100644 --- a/tests/Client/RequestTest.php +++ b/tests/Client/RequestTest.php @@ -18,22 +18,22 @@ $jar = CookieJar::fromArray(['Foo' => 'Bar', 'identity' => 'xyz'], 'local.example'); $curl = $this->curlFormatter->format($request, ['cookies' => $jar]); - expect($curl)->not()->toContain("-H 'Host: local.example'"); - expect($curl)->toContain("-b 'Foo=Bar; identity=xyz'"); + expect(str_replace('"', '\'', $curl))->not()->toContain("-H 'Host: local.example'"); + expect(str_replace('"', '\'', $curl))->toContain("-b 'Foo=Bar; identity=xyz'"); }); test('POST', function () { $request = new Request('POST', 'http://local.example', [], Utils::streamFor('foo=bar&hello=world')); $curl = $this->curlFormatter->format($request); - expect($curl)->toContain("-d 'foo=bar&hello=world'"); + expect(str_replace('"', '\'', $curl))->toContain("-d 'foo=bar&hello=world'"); }); test('PUT', function () { $request = new Request('PUT', 'http://local.example', [], Utils::streamFor('foo=bar&hello=world')); $curl = $this->curlFormatter->format($request); - expect($curl)->toContain("-d 'foo=bar&hello=world'"); + expect(str_replace('"', '\'', $curl))->toContain("-d 'foo=bar&hello=world'"); expect($curl)->toContain('-X PUT'); }); @@ -48,7 +48,7 @@ $request = new Request('HEAD', 'http://local.example'); $curl = $this->curlFormatter->format($request); - expect($curl)->toContain("curl 'http://local.example' --head"); + expect(str_replace('"', '\'', $curl))->toContain("curl 'http://local.example' --head"); }); test('OPTIONS', function () { @@ -56,4 +56,4 @@ $curl = $this->curlFormatter->format($request); expect($curl)->toContain('-X OPTIONS'); -}); \ No newline at end of file +}); diff --git a/tests/Formatter/CurlFormatterTest.php b/tests/Formatter/CurlFormatterTest.php index bc952b5..ee5dfd4 100644 --- a/tests/Formatter/CurlFormatterTest.php +++ b/tests/Formatter/CurlFormatterTest.php @@ -21,47 +21,47 @@ $request = new Request('GET', 'http://example.local'); $curl = $this->curlFormatter->format($request); - $this->assertEquals("curl 'http://example.local'", $curl); + $this->assertEquals("curl 'http://example.local'", str_replace('"', '\'', $curl)); }); test('simple get', function () { $request = new Request('GET', 'http://example.local'); $curl = $this->curlFormatter->format($request); - $this->assertEquals("curl 'http://example.local'", $curl); + $this->assertEquals("curl 'http://example.local'", str_replace('"', '\'', $curl)); }); test('simple GET with header', function () { $request = new Request('GET', 'http://example.local', ['foo' => 'bar']); $curl = $this->curlFormatter->format($request); - $this->assertEquals("curl 'http://example.local' -H 'foo: bar'", $curl); + $this->assertEquals("curl 'http://example.local' -H 'foo: bar'", str_replace('"', '\'', $curl)); }); test('simple GET with multiple header', function () { $request = new Request('GET', 'http://example.local', ['foo' => 'bar', 'Accept-Encoding' => 'gzip,deflate,sdch']); $curl = $this->curlFormatter->format($request); - $this->assertEquals("curl 'http://example.local' -H 'foo: bar' -H 'Accept-Encoding: gzip,deflate,sdch'", $curl); + $this->assertEquals("curl 'http://example.local' -H 'foo: bar' -H 'Accept-Encoding: gzip,deflate,sdch'", str_replace('"', '\'', $curl)); }); test('GET With Query String', function () { $request = new Request('GET', 'http://example.local?foo=bar'); $curl = $this->curlFormatter->format($request); - $this->assertEquals("curl 'http://example.local?foo=bar'", $curl); + $this->assertEquals("curl 'http://example.local?foo=bar'", str_replace('"', '\'', $curl)); $request = new Request('GET', 'http://example.local?foo=bar'); $curl = $this->curlFormatter->format($request); - $this->assertEquals("curl 'http://example.local?foo=bar'", $curl); + $this->assertEquals("curl 'http://example.local?foo=bar'", str_replace('"', '\'', $curl)); $body = Utils::streamFor(http_build_query(['foo' => 'bar', 'hello' => 'world'], '', '&')); $request = new Request('GET', 'http://example.local',[],$body); $curl = $this->curlFormatter->format($request); - $this->assertEquals("curl 'http://example.local' -G -d 'foo=bar&hello=world'",$curl); + $this->assertEquals("curl 'http://example.local' -G -d 'foo=bar&hello=world'", str_replace('"', '\'', $curl)); }); test('POST', function () { @@ -71,7 +71,8 @@ $curl = $this->curlFormatter->format($request); expect($curl)->not()->toContain(" -G "); - expect($curl)->toContain("-d 'foo=bar&hello=world'"); + expect(str_replace('"', '\'', $curl))->toContain("-d 'foo=bar&hello=world'"); + }); test('large POST request', function () { @@ -110,7 +111,7 @@ $request = new Request('PUT', 'http://example.local', [], Utils::streamFor('foo=bar&hello=world')); $curl = $this->curlFormatter->format($request); - expect($curl)->toContain("-d 'foo=bar&hello=world'"); + expect(str_replace('"', '\'', $curl))->toContain("-d 'foo=bar&hello=world'"); expect($curl)->toContain("-X PUT"); }); @@ -118,7 +119,7 @@ $request = new Request('PUT', 'http://example.local', [], Utils::streamFor('foo=bar&hello=world')); $curl = $this->curlFormatter->format($request); - expect($curl)->toContain("-d 'foo=bar&hello=world'"); + expect(str_replace('"', '\'', $curl))->toContain("-d 'foo=bar&hello=world'"); expect($curl)->toContain("-X PUT"); });