diff --git a/system/Config/BaseService.php b/system/Config/BaseService.php index 38bac37fdaa9..d33035fd974a 100644 --- a/system/Config/BaseService.php +++ b/system/Config/BaseService.php @@ -288,7 +288,7 @@ public static function reset(bool $initAutoloader = false) */ public static function resetSingle(string $name) { - unset(static::$mocks[$name], static::$instances[$name]); + unset(static::$mocks[strtolower($name)], static::$instances[strtolower($name)]); } /** diff --git a/tests/_support/Config/Services.php b/tests/_support/Config/Services.php index 4a942a053433..95df60a60058 100644 --- a/tests/_support/Config/Services.php +++ b/tests/_support/Config/Services.php @@ -14,6 +14,7 @@ use CodeIgniter\HTTP\URI; use Config\Services as BaseServices; use RuntimeException; +use stdClass; /** * Services Class @@ -43,4 +44,20 @@ public static function uri(?string $uri = null, bool $getShared = true) return new URI($uri); } + + /** + * The URI class provides a way to model and manipulate URIs. + * + * @param mixed $getShared + * + * @return stdClass + */ + public static function someService($getShared = true) + { + if ($getShared) { + return static::getSharedInstance('someService'); + } + + return new stdClass(); + } } diff --git a/tests/system/Config/ServicesTest.php b/tests/system/Config/ServicesTest.php index 7fed04f53aa3..43329ec4c498 100644 --- a/tests/system/Config/ServicesTest.php +++ b/tests/system/Config/ServicesTest.php @@ -343,6 +343,17 @@ public function testResetSingle() $this->assertSame($security, $security2); } + public function testResetSingleCaseInsensitive() + { + Services::injectMock('someService', new App()); + $someService = service('someService'); + $this->assertInstanceOf(App::class, $someService); + + Services::resetSingle('someService'); + $someService = service('someService'); + $this->assertNotInstanceOf(App::class, $someService); + } + public function testFilters() { $result = Services::filters();