17
17
class ClientTest extends TestCase
18
18
{
19
19
/**
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.
21
36
*
22
37
* @link https://github.com/php-http/curl-client/issues/18
23
38
*/
24
- public function testExpectHeader (): void
39
+ public function testExpectHeaderIsEmpty (): void
25
40
{
26
41
$ client = $ this ->createMock (Client::class);
27
42
@@ -36,11 +51,11 @@ public function testExpectHeader(): void
36
51
}
37
52
38
53
/**
39
- * "Expect" header should be empty.
54
+ * "Expect" header should be empty when POST field is empty .
40
55
*
41
56
* @link https://github.com/php-http/curl-client/issues/18
42
57
*/
43
- public function testWithNullPostFields (): void
58
+ public function testExpectHeaderIsEmpty2 (): void
44
59
{
45
60
$ client = $ this ->createMock (Client::class);
46
61
@@ -55,21 +70,6 @@ public function testWithNullPostFields(): void
55
70
self ::assertContains ('content-length: 0 ' , $ headers );
56
71
}
57
72
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
-
73
73
public function testRewindLargeStream (): void
74
74
{
75
75
$ client = $ this ->createMock (Client::class);
@@ -88,21 +88,24 @@ public function testRewindLargeStream(): void
88
88
$ request = new Request ('http://foo.com ' , 'POST ' , $ body );
89
89
$ options = $ bodyOptions ->invoke ($ client , $ request , []);
90
90
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
+ );
92
95
}
93
96
94
- /**
95
- * Tests throwing InvalidArgumentException when invalid cURL options passed to constructor.
96
- */
97
- public function testInvalidCurlOptions (): void
97
+ public function testRewindStream (): void
98
98
{
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 ]);
107
110
}
108
111
}
0 commit comments