File tree Expand file tree Collapse file tree
tests/system/Validation/StrictRules Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919use CodeIgniter \Test \CIUnitTestCase ;
2020use CodeIgniter \Validation \Validation ;
2121use PHPUnit \Framework \Attributes \Group ;
22+ use PHPUnit \Framework \Attributes \PreserveGlobalState ;
23+ use PHPUnit \Framework \Attributes \RunInSeparateProcess ;
2224use 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] ' ]);
You can’t perform that action at this time.
0 commit comments