Skip to content

Commit

Permalink
Merge pull request #5596 from najdanovicivan/services-resetSingle
Browse files Browse the repository at this point in the history
  • Loading branch information
MGatner committed Jan 23, 2022
2 parents 8922046 + 8207e27 commit f1054c2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions system/Config/BaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

Expand Down
11 changes: 11 additions & 0 deletions tests/system/Config/ServicesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit f1054c2

Please sign in to comment.