From 33b5ce1794593929054cf6f7f6b1604fc4a6048d Mon Sep 17 00:00:00 2001 From: Bruno Silva Date: Fri, 24 May 2024 10:00:29 +0200 Subject: [PATCH] Type-hint contract instead of concrete class to allow switching features --- src/Support/FeatureFake.php | 3 +-- tests/Support/FeatureFakeTest.php | 8 ++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Support/FeatureFake.php b/src/Support/FeatureFake.php index 31b6f18..fcf742a 100644 --- a/src/Support/FeatureFake.php +++ b/src/Support/FeatureFake.php @@ -9,7 +9,6 @@ use YlsIdeas\FeatureFlags\Contracts\Features; use YlsIdeas\FeatureFlags\Events\FeatureAccessed; use YlsIdeas\FeatureFlags\Events\FeatureAccessing; -use YlsIdeas\FeatureFlags\Manager; /** * @see \YlsIdeas\FeatureFlags\Tests\Support\FeatureFakeTest @@ -23,7 +22,7 @@ class FeatureFake implements Features /** * @param array $featureFlags */ - public function __construct(protected Manager $manager, protected array $featureFlags = []) + public function __construct(protected Features $manager, protected array $featureFlags = []) { } diff --git a/tests/Support/FeatureFakeTest.php b/tests/Support/FeatureFakeTest.php index c1ccde2..214940a 100644 --- a/tests/Support/FeatureFakeTest.php +++ b/tests/Support/FeatureFakeTest.php @@ -47,6 +47,14 @@ public function test_it_can_be_fake_accessibility_results() $this->assertTrue($fake->accessible('my-feature')); } + public function test_it_can_switch_a_feature_multiple_times() + { + Features::fake(['my-feature' => true]); + Features::fake(['my-feature' => false]); + + $this->assertFalse(Features::accessible('my-feature')); + } + public function test_it_can_be_fake_accessibility_results_from_the_container() { Event::fake();