diff --git a/app/Features/Operation.php b/app/Features/Operation.php new file mode 100644 index 00000000..abe6b85b --- /dev/null +++ b/app/Features/Operation.php @@ -0,0 +1,18 @@ +name = 'operation'; + } + + public function resolve(): bool + { + return true; + } +} diff --git a/app/Providers/FeatureFlagsServiceProvider.php b/app/Providers/FeatureFlagsServiceProvider.php index eec4611a..4fbae52a 100644 --- a/app/Providers/FeatureFlagsServiceProvider.php +++ b/app/Providers/FeatureFlagsServiceProvider.php @@ -2,6 +2,7 @@ namespace App\Providers; +use App\Features\Operation; use Illuminate\Support\ServiceProvider; use Laravel\Pennant\Feature; @@ -9,6 +10,6 @@ class FeatureFlagsServiceProvider extends ServiceProvider { public function boot(): void { - Feature::define('operation', fn() => true); + Feature::define(Operation::class); } } diff --git a/tests/Feature/Http/Controllers/User/CatalogPageTest.php b/tests/Feature/Http/Controllers/User/CatalogPageTest.php index e4ee341a..7f8fad8c 100644 --- a/tests/Feature/Http/Controllers/User/CatalogPageTest.php +++ b/tests/Feature/Http/Controllers/User/CatalogPageTest.php @@ -2,6 +2,7 @@ namespace Tests\Feature\Http\Controllers\User; +use App\Features\Operation; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Support\Facades\Artisan; use Laravel\Pennant\Feature; @@ -25,7 +26,7 @@ public function seeCartItemWhenFeatureOn() { Artisan::call('db:seed'); - Feature::activate('operation'); + Feature::activate(Operation::class); $this->get('/catalog') ->assertSeeText('Add to cart'); @@ -36,7 +37,7 @@ public function dontSeeCartItemWhenFeatureOff() { Artisan::call('db:seed'); - Feature::deactivate('operation'); + Feature::deactivate(Operation::class); $this->get('/catalog') ->assertDontSeeText('Add to cart'); diff --git a/tests/Feature/Http/Controllers/User/ShopTest.php b/tests/Feature/Http/Controllers/User/ShopTest.php index cc522970..5f7d4707 100644 --- a/tests/Feature/Http/Controllers/User/ShopTest.php +++ b/tests/Feature/Http/Controllers/User/ShopTest.php @@ -2,6 +2,7 @@ namespace Tests\Feature\Http\Controllers\User; +use App\Features\Operation; use Illuminate\Foundation\Testing\RefreshDatabase; use Laravel\Pennant\Feature; use PHPUnit\Framework\Attributes\Test; @@ -22,7 +23,7 @@ public function seeBasicTitle() #[Test] public function seeLoginItemWhenOperationFeatureOn() { - Feature::activate('operation'); + Feature::activate(Operation::class); $this->get('/catalog') ->assertSeeText('Track my order') @@ -33,7 +34,7 @@ public function seeLoginItemWhenOperationFeatureOn() #[Test] public function dontSeeLoginItemWhenOperationFeatureOff() { - Feature::deactivate('operation'); + Feature::deactivate(Operation::class); $this->get('/catalog') ->assertDontSeeText('Track my order')