mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
Merge pull request #7890 from kenjis/fix-test-forceGlobalSecureRequests
fix: FeatureTest fails when forceGlobalSecureRequests is true
This commit is contained in:
commit
daa88116d6
@ -296,6 +296,9 @@ trait FeatureTestTrait
|
||||
|
||||
if ($config->forceGlobalSecureRequests) {
|
||||
$_SERVER['HTTPS'] = 'test';
|
||||
$server = $request->getServer();
|
||||
$server['HTTPS'] = 'test';
|
||||
$request->setGlobal('server', $server);
|
||||
}
|
||||
|
||||
return $request;
|
||||
|
@ -15,6 +15,8 @@ use CodeIgniter\Config\Factories;
|
||||
use CodeIgniter\Events\Events;
|
||||
use CodeIgniter\Exceptions\PageNotFoundException;
|
||||
use CodeIgniter\HTTP\Response;
|
||||
use CodeIgniter\Test\Mock\MockCodeIgniter;
|
||||
use Config\App;
|
||||
use Config\Routing;
|
||||
use Config\Services;
|
||||
|
||||
@ -644,4 +646,19 @@ final class FeatureTestTraitTest extends CIUnitTestCase
|
||||
|
||||
$response->assertOK();
|
||||
}
|
||||
|
||||
public function testForceGlobalSecureRequests()
|
||||
{
|
||||
$config = config(App::class);
|
||||
$config->forceGlobalSecureRequests = true;
|
||||
Factories::injectMock('config', App::class, $config);
|
||||
|
||||
$this->app = new MockCodeIgniter($config);
|
||||
$this->app->initialize();
|
||||
|
||||
$response = $this->get('/');
|
||||
|
||||
// Do not redirect.
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user