Skip to content

Commit f53a1da

Browse files
committed
refactor: move Config\App::$CURLRequestShareOptions to Config\CURLRequest::$shareOptions
1 parent a6c06cc commit f53a1da

5 files changed

Lines changed: 41 additions & 19 deletions

File tree

app/Config/App.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -461,15 +461,4 @@ class App extends BaseConfig
461461
* @var bool
462462
*/
463463
public $CSPEnabled = false;
464-
465-
/**
466-
* --------------------------------------------------------------------------
467-
* CURLRequest Share Options
468-
* --------------------------------------------------------------------------
469-
*
470-
* Whether share options between requests or not.
471-
*
472-
* @var bool
473-
*/
474-
public $CURLRequestShareOptions = true;
475464
}

app/Config/CURLRequest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Config;
4+
5+
use CodeIgniter\Config\BaseConfig;
6+
7+
class CURLRequest extends BaseConfig
8+
{
9+
/**
10+
* --------------------------------------------------------------------------
11+
* CURLRequest Share Options
12+
* --------------------------------------------------------------------------
13+
*
14+
* Whether share options between requests or not.
15+
*
16+
* @var bool
17+
*/
18+
public $shareOptions = true;
19+
}

system/HTTP/CURLRequest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use CodeIgniter\HTTP\Exceptions\HTTPException;
1515
use Config\App;
16+
use Config\CURLRequest as ConfigCURLRequest;
1617
use InvalidArgumentException;
1718

1819
/**
@@ -116,9 +117,12 @@ public function __construct(App $config, URI $uri, ?ResponseInterface $response
116117
$this->response = $response;
117118
$this->baseURI = $uri->useRawQueryString();
118119
$this->defaultOptions = $options;
119-
$this->config = $this->defaultConfig;
120-
$this->shareOptions = $config->CURLRequestShareOptions ?? true;
121120

121+
/** @var ConfigCURLRequest|null $configCURLRequest */
122+
$configCURLRequest = config('CURLRequest');
123+
$this->shareOptions = $configCURLRequest->shareOptions ?? true;
124+
125+
$this->config = $this->defaultConfig;
122126
$this->parseOptions($options);
123127
}
124128

tests/system/HTTP/CURLRequestDoNotShareOptionsTest.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111

1212
namespace CodeIgniter\HTTP;
1313

14+
use CodeIgniter\Config\Factories;
1415
use CodeIgniter\Config\Services;
1516
use CodeIgniter\HTTP\Exceptions\HTTPException;
1617
use CodeIgniter\Test\CIUnitTestCase;
1718
use CodeIgniter\Test\Mock\MockCURLRequest;
1819
use Config\App;
20+
use Config\CURLRequest as ConfigCURLRequest;
1921
use CURLFile;
2022

2123
/**
@@ -38,9 +40,12 @@ protected function setUp(): void
3840

3941
protected function getRequest(array $options = [])
4042
{
41-
$uri = isset($options['base_uri']) ? new URI($options['base_uri']) : new URI();
42-
$app = new App();
43-
$app->CURLRequestShareOptions = false;
43+
$uri = isset($options['base_uri']) ? new URI($options['base_uri']) : new URI();
44+
$app = new App();
45+
46+
$config = new ConfigCURLRequest();
47+
$config->shareOptions = false;
48+
Factories::injectMock('config', 'CURLRequest', $config);
4449

4550
return new MockCURLRequest(($app), $uri, new Response($app), $options);
4651
}

tests/system/HTTP/CURLRequestTest.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111

1212
namespace CodeIgniter\HTTP;
1313

14+
use CodeIgniter\Config\Factories;
1415
use CodeIgniter\Config\Services;
1516
use CodeIgniter\HTTP\Exceptions\HTTPException;
1617
use CodeIgniter\Test\CIUnitTestCase;
1718
use CodeIgniter\Test\Mock\MockCURLRequest;
1819
use Config\App;
20+
use Config\CURLRequest as ConfigCURLRequest;
1921
use CURLFile;
2022

2123
/**
@@ -38,9 +40,12 @@ protected function setUp(): void
3840

3941
protected function getRequest(array $options = [])
4042
{
41-
$uri = isset($options['base_uri']) ? new URI($options['base_uri']) : new URI();
42-
$app = new App();
43-
$app->CURLRequestShareOptions = true;
43+
$uri = isset($options['base_uri']) ? new URI($options['base_uri']) : new URI();
44+
$app = new App();
45+
46+
$config = new ConfigCURLRequest();
47+
$config->shareOptions = true;
48+
Factories::injectMock('config', 'CURLRequest', $config);
4449

4550
return new MockCURLRequest(($app), $uri, new Response($app), $options);
4651
}

0 commit comments

Comments
 (0)