Skip to content

Commit 7231481

Browse files
committed
fix test
1 parent bbc2224 commit 7231481

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

tests/system/Validation/StrictRules/FileRulesTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
use CodeIgniter\Test\CIUnitTestCase;
2020
use CodeIgniter\Validation\Validation;
2121
use PHPUnit\Framework\Attributes\Group;
22+
use PHPUnit\Framework\Attributes\PreserveGlobalState;
23+
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
2224
use Tests\Support\Validation\TestRules;
2325

2426
/**
@@ -164,11 +166,15 @@ public function testUploadedPassesForSingleValidFile(): void
164166
$this->assertTrue($this->validation->run([]));
165167
}
166168

169+
#[PreserveGlobalState(false)]
170+
#[RunInSeparateProcess]
167171
public function testUploadedFailsInProductionWhenFileWasNotHttpUpload(): void
168172
{
169173
// Counterpart to testUploadedPassesForSingleValidFile: the same fixture
170174
// passes in the testing env but must fail in production, where isValid()
171-
// enforces is_uploaded_file().
175+
// enforces is_uploaded_file(). Runs in a separate process because the
176+
// namespace-level is_uploaded_file() override in FileMovingTest.php would
177+
// otherwise leak in and make the fixture appear to be a valid upload.
172178
Services::injectMock('environmentdetector', new EnvironmentDetector('production'));
173179

174180
$this->validation->setRules(['avatar' => 'uploaded[avatar]']);

0 commit comments

Comments
 (0)