From 3ae0e24ddb89d13932af23450c44a33882328d27 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Thu, 11 Apr 2024 11:17:04 +0200 Subject: [PATCH] Simplify internal feature mocking to remove array support We don't use this anywhere but a test, so no reason to have it. It also lets us remove the null type. --- .../Framework/Concerns/Internal/MockableFeatures.php | 12 +----------- .../tests/Feature/ConfigurableFeaturesTest.php | 12 ++++-------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/packages/framework/src/Framework/Concerns/Internal/MockableFeatures.php b/packages/framework/src/Framework/Concerns/Internal/MockableFeatures.php index 008a9e1ddf4..0fb40d28f88 100644 --- a/packages/framework/src/Framework/Concerns/Internal/MockableFeatures.php +++ b/packages/framework/src/Framework/Concerns/Internal/MockableFeatures.php @@ -7,8 +7,6 @@ use Hyde\Enums\Feature; use Illuminate\Support\Str; -use function is_array; - /** * Allows the Features class to be mocked. * @@ -20,16 +18,8 @@ trait MockableFeatures { protected static array $mockedInstances = []; - public static function mock(string|array $feature, ?bool $enabled = null): void + public static function mock(string $feature, bool $enabled): void { - if (is_array($feature)) { - foreach ($feature as $key => $value) { - static::mock($key, $value); - } - - return; - } - static::$mockedInstances[Str::studly($feature)] = $enabled; } diff --git a/packages/framework/tests/Feature/ConfigurableFeaturesTest.php b/packages/framework/tests/Feature/ConfigurableFeaturesTest.php index a7ce65f0e84..d00e4ab79ed 100644 --- a/packages/framework/tests/Feature/ConfigurableFeaturesTest.php +++ b/packages/framework/tests/Feature/ConfigurableFeaturesTest.php @@ -106,18 +106,14 @@ public function testDynamicFeaturesCanBeMocked() public function testMultipleFeaturesCanBeMocked() { - Features::mock([ - 'rss' => true, - 'darkmode' => true, - ]); + Features::mock('rss', true); + Features::mock('darkmode', true); $this->assertTrue(Features::rss()); $this->assertTrue(Features::hasDarkmode()); - Features::mock([ - 'rss' => false, - 'darkmode' => false, - ]); + Features::mock('rss', false); + Features::mock('darkmode', false); $this->assertFalse(Features::rss()); $this->assertFalse(Features::hasDarkmode());