Skip to content
2 changes: 1 addition & 1 deletion .github/scripts/random-tests-config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Events
Files
# Filters
Format
# HTTP
HTTP
# Helpers
Honeypot
HotReloader
Expand Down
2 changes: 1 addition & 1 deletion tests/system/HTTP/CURLRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class CURLRequestTest extends CIUnitTestCase

protected function setUp(): void
{
$this->resetServices();
parent::setUp();

$this->resetServices();
Services::injectMock('superglobals', new Superglobals());
$this->request = $this->getRequest();
}
Expand Down
8 changes: 8 additions & 0 deletions tests/system/HTTP/CorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,22 @@
namespace CodeIgniter\HTTP;

use CodeIgniter\Test\CIUnitTestCase;
use PHPUnit\Framework\Attributes\BackupGlobals;
use PHPUnit\Framework\Attributes\Group;

/**
* @internal
*/
#[BackupGlobals(true)]
#[Group('Others')]
final class CorsTest extends CIUnitTestCase
{
protected function setUp(): void
{
$this->resetServices();
parent::setUp();
}

/**
* @param array{
* allowedOrigins?: list<string>,
Expand Down
2 changes: 2 additions & 0 deletions tests/system/HTTP/DownloadResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use CodeIgniter\Test\CIUnitTestCase;
use DateTime;
use DateTimeZone;
use PHPUnit\Framework\Attributes\BackupGlobals;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\PreserveGlobalState;
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
Expand All @@ -28,6 +29,7 @@
/**
* @internal
*/
#[BackupGlobals(true)]
#[Group('SeparateProcess')]
final class DownloadResponseTest extends CIUnitTestCase
{
Expand Down
7 changes: 4 additions & 3 deletions tests/system/HTTP/IncomingRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ final class IncomingRequestTest extends CIUnitTestCase
#[WithoutErrorHandler]
protected function setUp(): void
{
$this->resetServices();
parent::setUp();

$_ENV = $_SESSION = [];
Expand Down Expand Up @@ -280,7 +281,7 @@ public function testSetValidLocales(): void
*/
public function testNegotiatesLocale(): void
{
service('superglobals')->setServer('HTTP_ACCEPT_LANGUAGE', 'fr-FR); q=1.0, en; q=0.5');
service('superglobals')->setServer('HTTP_ACCEPT_LANGUAGE', 'fr-FR; q=1.0, en; q=0.5');

$config = new App();
$config->negotiateLocale = true;
Expand All @@ -295,7 +296,7 @@ public function testNegotiatesLocale(): void

public function testNegotiatesLocaleOnlyBroad(): void
{
service('superglobals')->setServer('HTTP_ACCEPT_LANGUAGE', 'fr); q=1.0, en; q=0.5');
service('superglobals')->setServer('HTTP_ACCEPT_LANGUAGE', 'fr; q=1.0, en; q=0.5');

$config = new App();
$config->negotiateLocale = true;
Expand Down Expand Up @@ -349,7 +350,7 @@ public function testNegotiatesEncoding(): void
public function testNegotiatesLanguage(): void
{
$this->request->setHeader('Accept-Language', 'da, en-gb;q=0.8, en;q=0.7');
$this->assertSame('en', $this->request->negotiate('language', ['en', 'da']));
$this->assertSame('da', $this->request->negotiate('language', ['en', 'da']));
}

public function testCanGrabGetRawJSON(): void
Expand Down
6 changes: 5 additions & 1 deletion tests/system/HTTP/MessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,11 @@ public function testPopulateHeadersWithoutContentType(): void

$this->assertNull($this->message->header('content-type'));

putenv("CONTENT_TYPE={$originalEnv}");
if ($originalEnv !== false) {
putenv("CONTENT_TYPE={$originalEnv}");
} else {
putenv('CONTENT_TYPE');
}
}

public function testPopulateHeadersWithoutHTTP(): void
Expand Down
3 changes: 3 additions & 0 deletions tests/system/HTTP/NegotiateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
use CodeIgniter\Test\CIUnitTestCase;
use Config\App;
use Config\Feature;
use PHPUnit\Framework\Attributes\BackupGlobals;
use PHPUnit\Framework\Attributes\Group;

/**
* @internal
*/
#[BackupGlobals(true)]
#[Group('Others')]
final class NegotiateTest extends CIUnitTestCase
{
Expand All @@ -30,6 +32,7 @@ final class NegotiateTest extends CIUnitTestCase

protected function setUp(): void
{
$this->resetServices();
parent::setUp();

$config = new App();
Expand Down
5 changes: 3 additions & 2 deletions tests/system/HTTP/RedirectResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Config\Modules;
use Config\Routing;
use Config\Services;
use PHPUnit\Framework\Attributes\BackupGlobals;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\PreserveGlobalState;
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
Expand All @@ -32,6 +33,7 @@
/**
* @internal
*/
#[BackupGlobals(true)]
#[Group('SeparateProcess')]
final class RedirectResponseTest extends CIUnitTestCase
{
Expand All @@ -46,9 +48,8 @@ final class RedirectResponseTest extends CIUnitTestCase
#[WithoutErrorHandler]
protected function setUp(): void
{
parent::setUp();

$this->resetServices();
parent::setUp();

Services::injectMock('superglobals', new Superglobals());
service('superglobals')->setServer('REQUEST_METHOD', 'GET');
Expand Down
10 changes: 6 additions & 4 deletions tests/system/HTTP/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,26 @@
use Config\App;
use DateTime;
use DateTimeZone;
use PHPUnit\Framework\Attributes\BackupGlobals;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;

/**
* @internal
*/
#[BackupGlobals(true)]
#[Group('Others')]
final class ResponseTest extends CIUnitTestCase
{
private array $server;

protected function setUp(): void
{
Services::injectMock('superglobals', new Superglobals());
$this->server = service('superglobals')->getServerArray();

$this->resetServices();
parent::setUp();

$this->resetServices();
Services::injectMock('superglobals', new Superglobals());
$this->server = service('superglobals')->getServerArray();
}

protected function tearDown(): void
Expand Down Expand Up @@ -169,6 +170,7 @@ public function testSetLink(): void
Factories::injectMock('config', 'App', $config);

$this->resetServices();
Services::injectMock('superglobals', new Superglobals([], []));

$response = new Response($config);
$pager = service('pager');
Expand Down
3 changes: 3 additions & 0 deletions tests/system/HTTP/UserAgentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
namespace CodeIgniter\HTTP;

use CodeIgniter\Test\CIUnitTestCase;
use PHPUnit\Framework\Attributes\BackupGlobals;
use PHPUnit\Framework\Attributes\Group;

/**
* @internal
*/
#[BackupGlobals(true)]
#[Group('Others')]
final class UserAgentTest extends CIUnitTestCase
{
Expand All @@ -28,6 +30,7 @@ final class UserAgentTest extends CIUnitTestCase

protected function setUp(): void
{
$this->resetServices();
parent::setUp();

// set a baseline user agent
Expand Down
Loading