2323use CURLFile ;
2424
2525/**
26+ * This test case is for the case where shareOptions is true.
27+ * The shareOptions should be set to false.
28+ *
2629 * @internal
2730 *
2831 * @group Others
2932 */
30- final class CURLRequestDoNotShareOptionsTest extends CIUnitTestCase
33+ final class CURLRequestShareOptionsTest extends CIUnitTestCase
3134{
3235 private MockCURLRequest $ request ;
3336
@@ -45,7 +48,7 @@ protected function getRequest(array $options = []): MockCURLRequest
4548 $ app = new App ();
4649
4750 $ config = new ConfigCURLRequest ();
48- $ config ->shareOptions = false ;
51+ $ config ->shareOptions = true ;
4952 Factories::injectMock ('config ' , 'CURLRequest ' , $ config );
5053
5154 return new MockCURLRequest (($ app ), $ uri , new Response ($ app ), $ options );
@@ -226,23 +229,6 @@ public function testDefaultOptionsAreSharedBetweenRequests(): void
226229 $ this ->assertSame ('CodeIgniter Framework v4 ' , $ request ->curl_options [CURLOPT_USERAGENT ]);
227230 }
228231
229- public function testHeaderContentLengthNotSharedBetweenRequests (): void
230- {
231- $ options = [
232- 'base_uri ' => 'http://www.foo.com/api/v1/ ' ,
233- ];
234- $ request = $ this ->getRequest ($ options );
235-
236- $ request ->post ('example ' , [
237- 'form_params ' => [
238- 'q ' => 'keyword ' ,
239- ],
240- ]);
241- $ request ->get ('example ' );
242-
243- $ this ->assertNull ($ request ->header ('Content-Length ' ));
244- }
245-
246232 /**
247233 * @backupGlobals enabled
248234 */
@@ -960,21 +946,6 @@ public function testApplyBodyByOptions(): void
960946 $ this ->assertSame ('name=George ' , $ request ->curl_options [CURLOPT_POSTFIELDS ]);
961947 }
962948
963- public function testBodyIsResetOnSecondRequest (): void
964- {
965- $ request = $ this ->getRequest ([
966- 'base_uri ' => 'http://www.foo.com/api/v1/ ' ,
967- 'delay ' => 100 ,
968- ]);
969- $ request ->setBody ('name=George ' );
970- $ request ->setOutput ('Hi there ' );
971-
972- $ request ->post ('answer ' );
973- $ request ->post ('answer ' );
974-
975- $ this ->assertArrayNotHasKey (CURLOPT_POSTFIELDS , $ request ->curl_options );
976- }
977-
978949 public function testResponseHeaders (): void
979950 {
980951 $ request = $ this ->getRequest ([
@@ -1094,6 +1065,7 @@ public function testJSONData(): void
10941065 $ expected ,
10951066 $ this ->request ->curl_options [CURLOPT_POSTFIELDS ]
10961067 );
1068+ $ this ->assertSame ($ expected , $ this ->request ->getBody ());
10971069 }
10981070
10991071 public function testSetJSON (): void
@@ -1112,6 +1084,8 @@ public function testSetJSON(): void
11121084 $ expected ,
11131085 $ this ->request ->curl_options [CURLOPT_POSTFIELDS ]
11141086 );
1087+ $ this ->assertSame ($ expected , $ this ->request ->getBody ());
1088+
11151089 $ this ->assertSame (
11161090 'Content-Type: application/json ' ,
11171091 $ this ->request ->curl_options [CURLOPT_HTTPHEADER ][0 ]
0 commit comments