1717class ClientTest extends TestCase
1818{
1919 /**
20- * "Expect" header should be empty.
20+ * Tests throwing InvalidArgumentException when invalid cURL options passed to constructor.
21+ */
22+ public function testExceptionThrownOnInvalidCurlOptions (): void
23+ {
24+ $ this ->expectException (InvalidOptionsException::class);
25+ new Client (
26+ $ this ->createMock (ResponseFactoryInterface::class),
27+ $ this ->createMock (StreamFactoryInterface::class),
28+ [
29+ CURLOPT_HEADER => true , // this won't work with our client
30+ ]
31+ );
32+ }
33+
34+ /**
35+ * "Expect" header should be empty by default.
2136 *
2237 * @link https://github.com/php-http/curl-client/issues/18
2338 */
24- public function testExpectHeader (): void
39+ public function testExpectHeaderIsEmpty (): void
2540 {
2641 $ client = $ this ->createMock (Client::class);
2742
@@ -36,11 +51,11 @@ public function testExpectHeader(): void
3651 }
3752
3853 /**
39- * "Expect" header should be empty.
54+ * "Expect" header should be empty when POST field is empty .
4055 *
4156 * @link https://github.com/php-http/curl-client/issues/18
4257 */
43- public function testWithNullPostFields (): void
58+ public function testExpectHeaderIsEmpty2 (): void
4459 {
4560 $ client = $ this ->createMock (Client::class);
4661
@@ -55,21 +70,6 @@ public function testWithNullPostFields(): void
5570 self ::assertContains ('content-length: 0 ' , $ headers );
5671 }
5772
58- public function testRewindStream (): void
59- {
60- $ client = $ this ->createMock (Client::class);
61-
62- $ bodyOptions = new \ReflectionMethod (Client::class, 'addRequestBodyOptions ' );
63- $ bodyOptions ->setAccessible (true );
64-
65- $ body = \GuzzleHttp \Psr7 \stream_for ('abcdef ' );
66- $ body ->seek (3 );
67- $ request = new Request ('http://foo.com ' , 'POST ' , $ body );
68- $ options = $ bodyOptions ->invoke ($ client , $ request , []);
69-
70- static ::assertEquals ('abcdef ' , $ options [CURLOPT_POSTFIELDS ]);
71- }
72-
7373 public function testRewindLargeStream (): void
7474 {
7575 $ client = $ this ->createMock (Client::class);
@@ -88,21 +88,24 @@ public function testRewindLargeStream(): void
8888 $ request = new Request ('http://foo.com ' , 'POST ' , $ body );
8989 $ options = $ bodyOptions ->invoke ($ client , $ request , []);
9090
91- static ::assertTrue (false !== strstr ($ options [CURLOPT_READFUNCTION ](null , null , $ length ), 'abcdef ' ), 'Steam was not rewinded ' );
91+ static ::assertTrue (
92+ false !== strstr ($ options [CURLOPT_READFUNCTION ](null , null , $ length ), 'abcdef ' ),
93+ 'Steam was not rewinded '
94+ );
9295 }
9396
94- /**
95- * Tests throwing InvalidArgumentException when invalid cURL options passed to constructor.
96- */
97- public function testInvalidCurlOptions (): void
97+ public function testRewindStream (): void
9898 {
99- $ this ->expectException (InvalidOptionsException::class);
100- new Client (
101- $ this ->createMock (ResponseFactoryInterface::class),
102- $ this ->createMock (StreamFactoryInterface::class),
103- [
104- CURLOPT_HEADER => true , // this won't work with our client
105- ]
106- );
99+ $ client = $ this ->createMock (Client::class);
100+
101+ $ bodyOptions = new \ReflectionMethod (Client::class, 'addRequestBodyOptions ' );
102+ $ bodyOptions ->setAccessible (true );
103+
104+ $ body = \GuzzleHttp \Psr7 \stream_for ('abcdef ' );
105+ $ body ->seek (3 );
106+ $ request = new Request ('http://foo.com ' , 'POST ' , $ body );
107+ $ options = $ bodyOptions ->invoke ($ client , $ request , []);
108+
109+ static ::assertEquals ('abcdef ' , $ options [CURLOPT_POSTFIELDS ]);
107110 }
108111}
0 commit comments