diff --git a/.github/scripts/random-tests-config.txt b/.github/scripts/random-tests-config.txt index b5a05ade82ac..7887009dd132 100644 --- a/.github/scripts/random-tests-config.txt +++ b/.github/scripts/random-tests-config.txt @@ -14,7 +14,7 @@ Autoloader # Cache CLI # Commands -# Config +Config Cookie # DataCaster # DataConverter @@ -29,7 +29,7 @@ Files Format # HTTP # Helpers -# Honeypot +Honeypot HotReloader # I18n # Images @@ -42,7 +42,7 @@ RESTful # Router Security # Session -# Test +Test Throttle Typography # Validation diff --git a/tests/_support/Test/TestForReflectionHelper.php b/tests/_support/Test/TestForReflectionHelper.php index b277509aebdf..b354d87b9761 100644 --- a/tests/_support/Test/TestForReflectionHelper.php +++ b/tests/_support/Test/TestForReflectionHelper.php @@ -28,6 +28,11 @@ public static function getStaticPrivate() return self::$static_private; } + public static function resetStaticPrivate(): void + { + self::$static_private = 'xyz'; + } + private function privateMethod($param1, $param2) // @phpstan-ignore method.unused { return 'private ' . $param1 . $param2; diff --git a/tests/system/Config/BaseConfigTest.php b/tests/system/Config/BaseConfigTest.php index 5cc3d1682617..61a25e16aaa8 100644 --- a/tests/system/Config/BaseConfigTest.php +++ b/tests/system/Config/BaseConfigTest.php @@ -42,6 +42,7 @@ protected function setUp(): void { parent::setUp(); + $this->clearLooseEnvironmentOverrides(); $this->fixturesFolder = __DIR__ . '/fixtures'; if (! class_exists('SimpleConfig', false)) { @@ -65,12 +66,27 @@ protected function tearDown(): void { parent::tearDown(); + $this->clearLooseEnvironmentOverrides(); // This test modifies BaseConfig::$modules, so should reset. BaseConfig::reset(); // This test modifies Services locator, so should reset. $this->resetServices(); } + private function clearLooseEnvironmentOverrides(): void + { + foreach ([ + 'SimpleConfig.QZERO', + 'SimpleConfig.QZEROSTR', + 'SimpleConfig.QEMPTYSTR', + 'SimpleConfig.QFALSE', + ] as $key) { + putenv($key); + unset($_ENV[$key]); + Services::superglobals()->unsetServer($key); + } + } + public function testBasicValues(): void { $dotenv = new DotEnv($this->fixturesFolder, '.env'); diff --git a/tests/system/Config/FactoriesTest.php b/tests/system/Config/FactoriesTest.php index a3a4303dd3a0..37077c41b1a5 100644 --- a/tests/system/Config/FactoriesTest.php +++ b/tests/system/Config/FactoriesTest.php @@ -244,7 +244,7 @@ public function testPrioritizesParameterOptions(): void { Factories::setOptions('widgets', ['instanceOf' => 'stdClass']); - $result = Factories::widgets('OtherWidget', ['instanceOf' => null]); + $result = Factories::widgets(OtherWidget::class, ['instanceOf' => null]); $this->assertInstanceOf(OtherWidget::class, $result); } diff --git a/tests/system/Honeypot/HoneypotTest.php b/tests/system/Honeypot/HoneypotTest.php index 7389f7faea0b..12341f645889 100644 --- a/tests/system/Honeypot/HoneypotTest.php +++ b/tests/system/Honeypot/HoneypotTest.php @@ -50,6 +50,8 @@ protected function setUp(): void { parent::setUp(); + $this->resetServices(); + Factories::reset('config'); Services::injectMock('superglobals', new Superglobals()); $this->config = new HoneypotConfig(); diff --git a/tests/system/Test/FeatureTestTraitTest.php b/tests/system/Test/FeatureTestTraitTest.php index a5472ddd969d..f36767f7f971 100644 --- a/tests/system/Test/FeatureTestTraitTest.php +++ b/tests/system/Test/FeatureTestTraitTest.php @@ -671,6 +671,10 @@ public function testAutoRoutingLegacy(): void $config->autoRoute = true; Factories::injectMock('config', Routing::class, $config); + $collection = service('routes'); + $collection->setAutoRoute(true); + $collection->setDefaultNamespace('App\Controllers'); + $response = $this->get('home/index'); $response->assertOK(); diff --git a/tests/system/Test/ReflectionHelperTest.php b/tests/system/Test/ReflectionHelperTest.php index e110a4820422..41eb0d15d9d0 100644 --- a/tests/system/Test/ReflectionHelperTest.php +++ b/tests/system/Test/ReflectionHelperTest.php @@ -22,6 +22,13 @@ #[Group('Others')] final class ReflectionHelperTest extends CIUnitTestCase { + protected function setUp(): void + { + parent::setUp(); + + TestForReflectionHelper::resetStaticPrivate(); + } + public function testGetPrivatePropertyWithObject(): void { $obj = new TestForReflectionHelper();