Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/scripts/random-tests-config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Autoloader
# Cache
CLI
# Commands
# Config
Config
Cookie
# DataCaster
# DataConverter
Expand All @@ -29,7 +29,7 @@ Files
Format
# HTTP
# Helpers
# Honeypot
Honeypot
HotReloader
# I18n
# Images
Expand All @@ -42,7 +42,7 @@ RESTful
# Router
Security
# Session
# Test
Test
Throttle
Typography
# Validation
Expand Down
5 changes: 5 additions & 0 deletions tests/_support/Test/TestForReflectionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 16 additions & 0 deletions tests/system/Config/BaseConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ protected function setUp(): void
{
parent::setUp();

$this->clearLooseEnvironmentOverrides();
$this->fixturesFolder = __DIR__ . '/fixtures';

if (! class_exists('SimpleConfig', false)) {
Expand All @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion tests/system/Config/FactoriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 2 additions & 0 deletions tests/system/Honeypot/HoneypotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ protected function setUp(): void
{
parent::setUp();

$this->resetServices();
Factories::reset('config');
Services::injectMock('superglobals', new Superglobals());

$this->config = new HoneypotConfig();
Expand Down
4 changes: 4 additions & 0 deletions tests/system/Test/FeatureTestTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions tests/system/Test/ReflectionHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading