Skip to content

Commit 670bbe5

Browse files
committed
update tests
1 parent 5ba09f2 commit 670bbe5

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

tests/system/API/TransformerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ private function createMockRequest(string $query = ''): IncomingRequest
4444
if ($query !== '') {
4545
parse_str($query, $get);
4646
$request->setGlobal('get', $get);
47+
} else {
48+
$request->setGlobal('get', []);
4749
}
4850

4951
return $request;

tests/system/Log/LoggerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ public function testLogInterpolatesPost(): void
131131

132132
Time::setTestNow('2023-11-25 12:00:00');
133133

134-
$_POST = ['foo' => 'bar'];
135-
$expected = 'DEBUG - ' . Time::now()->format('Y-m-d') . ' --> Test message $_POST: ' . print_r($_POST, true);
134+
service('superglobals')->setPost('foo', 'bar');
135+
$expected = 'DEBUG - ' . Time::now()->format('Y-m-d') . ' --> Test message $_POST: ' . print_r(service('superglobals')->getPostArray(), true);
136136

137137
$logger->log('debug', 'Test message {post_vars}');
138138

@@ -150,8 +150,8 @@ public function testLogInterpolatesGet(): void
150150

151151
Time::setTestNow('2023-11-25 12:00:00');
152152

153-
$_GET = ['bar' => 'baz'];
154-
$expected = 'DEBUG - ' . Time::now()->format('Y-m-d') . ' --> Test message $_GET: ' . print_r($_GET, true);
153+
service('superglobals')->setGet('bar', 'baz');
154+
$expected = 'DEBUG - ' . Time::now()->format('Y-m-d') . ' --> Test message $_GET: ' . print_r(service('superglobals')->getGetArray(), true);
155155

156156
$logger->log('debug', 'Test message {get_vars}');
157157

tests/system/Pager/PagerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ protected function setUp(): void
4141
{
4242
parent::setUp();
4343

44+
$_SERVER = $_GET = $_POST = $_COOKIE = $_FILES = $_REQUEST = [];
45+
4446
Services::injectMock('superglobals', new Superglobals());
4547

4648
$this->createPager('/');

tests/system/SuperglobalsTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
namespace CodeIgniter;
1515

1616
use CodeIgniter\Test\CIUnitTestCase;
17+
use PHPUnit\Framework\Attributes\BackupGlobals;
1718
use PHPUnit\Framework\Attributes\Group;
1819

1920
/**
2021
* @internal
2122
*/
23+
#[BackupGlobals(true)]
2224
#[Group('Others')]
2325
final class SuperglobalsTest extends CIUnitTestCase
2426
{

tests/system/Validation/StrictRules/FileRulesTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected function setUp(): void
5858
$this->validation = new Validation((object) $this->config, service('renderer'));
5959
$this->validation->reset();
6060

61-
$_FILES = [
61+
service('superglobals')->setFilesArray([
6262
'avatar' => [
6363
'tmp_name' => TESTPATH . '_support/Validation/uploads/phpUxc0ty',
6464
'name' => 'my-avatar.png',
@@ -146,7 +146,13 @@ protected function setUp(): void
146146
400,
147147
],
148148
],
149-
];
149+
]);
150+
}
151+
152+
protected function tearDown(): void
153+
{
154+
parent::tearDown();
155+
service('superglobals')->setFilesArray([]);
150156
}
151157

152158
public function testUploadedTrue(): void

0 commit comments

Comments
 (0)