From 8207e2757539bf2f681007897cb15929279833fc Mon Sep 17 00:00:00 2001 From: Najdanovic Ivan Date: Wed, 19 Jan 2022 19:26:38 +0100 Subject: [PATCH] BaseService - Use lowercase key in resetSingle --- system/Config/BaseService.php | 1 + tests/system/Config/ServicesTest.php | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/system/Config/BaseService.php b/system/Config/BaseService.php index 38bac37fdaa9..572b6cf576bd 100644 --- a/system/Config/BaseService.php +++ b/system/Config/BaseService.php @@ -288,6 +288,7 @@ public static function reset(bool $initAutoloader = false) */ public static function resetSingle(string $name) { + $name = strtolower($name); unset(static::$mocks[$name], static::$instances[$name]); } diff --git a/tests/system/Config/ServicesTest.php b/tests/system/Config/ServicesTest.php index 7fed04f53aa3..5f8cc476ae88 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('response', new MockResponse(new App())); + $someService = service('response'); + $this->assertInstanceOf(MockResponse::class, $someService); + + Services::resetSingle('Response'); + $someService = service('response'); + $this->assertNotInstanceOf(MockResponse::class, $someService); + } + public function testFilters() { $result = Services::filters();