Skip to content

Commit 9e88ec4

Browse files
committed
test: add tests for sharing options
1 parent 436013e commit 9e88ec4

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

tests/system/HTTP/CURLRequestDoNotShareOptionsTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,27 @@ public function testOptionsHeadersNotUsingPopulate()
199199
$this->assertSame('', $request->header('Accept-Encoding')->getValue());
200200
}
201201

202+
public function testDefaultOptionsAreSharedBetweenRequests()
203+
{
204+
$options = [
205+
'form_params' => ['studio' => 1],
206+
'user_agent' => 'CodeIgniter Framework v4',
207+
];
208+
$request = $this->getRequest($options);
209+
210+
$request->request('POST', 'https://realestate1.example.com');
211+
212+
$this->assertSame('https://realestate1.example.com', $request->curl_options[CURLOPT_URL]);
213+
$this->assertSame('studio=1', $request->curl_options[CURLOPT_POSTFIELDS]);
214+
$this->assertSame('CodeIgniter Framework v4', $request->curl_options[CURLOPT_USERAGENT]);
215+
216+
$request->request('POST', 'https://realestate2.example.com');
217+
218+
$this->assertSame('https://realestate2.example.com', $request->curl_options[CURLOPT_URL]);
219+
$this->assertSame('studio=1', $request->curl_options[CURLOPT_POSTFIELDS]);
220+
$this->assertSame('CodeIgniter Framework v4', $request->curl_options[CURLOPT_USERAGENT]);
221+
}
222+
202223
public function testHeaderContentLengthNotSharedBetweenRequests()
203224
{
204225
$options = [

tests/system/HTTP/CURLRequestTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,27 @@ public function testOptionsHeadersNotUsingPopulate()
199199
$this->assertSame('', $request->header('Accept-Encoding')->getValue());
200200
}
201201

202+
public function testOptionsAreSharedBetweenRequests()
203+
{
204+
$options = [
205+
'form_params' => ['studio' => 1],
206+
'user_agent' => 'CodeIgniter Framework v4',
207+
];
208+
$request = $this->getRequest($options);
209+
210+
$request->request('POST', 'https://realestate1.example.com');
211+
212+
$this->assertSame('https://realestate1.example.com', $request->curl_options[CURLOPT_URL]);
213+
$this->assertSame('studio=1', $request->curl_options[CURLOPT_POSTFIELDS]);
214+
$this->assertSame('CodeIgniter Framework v4', $request->curl_options[CURLOPT_USERAGENT]);
215+
216+
$request->request('POST', 'https://realestate2.example.com');
217+
218+
$this->assertSame('https://realestate2.example.com', $request->curl_options[CURLOPT_URL]);
219+
$this->assertSame('studio=1', $request->curl_options[CURLOPT_POSTFIELDS]);
220+
$this->assertSame('CodeIgniter Framework v4', $request->curl_options[CURLOPT_USERAGENT]);
221+
}
222+
202223
/**
203224
* @backupGlobals enabled
204225
*/

0 commit comments

Comments
 (0)