Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type-hint contract instead of concrete class to allow switching features #66

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Support/FeatureFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,7 +22,7 @@ class FeatureFake implements Features
/**
* @param array<string, bool|array> $featureFlags
*/
public function __construct(protected Manager $manager, protected array $featureFlags = [])
public function __construct(protected Features $manager, protected array $featureFlags = [])
{
}

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