Skip to content

Commit

Permalink
Adds Feature Flag information to the About command (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterfox committed Jan 3, 2023
1 parent 37a39ac commit 08a47dd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/FeatureFlagsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Console\Scheduling\Event;
use Illuminate\Database\Query\Builder;
use Illuminate\Foundation\Console\AboutCommand;
use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Validator;
Expand Down Expand Up @@ -46,6 +47,8 @@ public function boot()
Commands\SwitchOffFeature::class,
]);
}

$this->aboutCommandInfo();
}

if (Features::usesValidations()) {
Expand Down Expand Up @@ -120,4 +123,13 @@ protected function queryBuilder()
{
Builder::mixin(new QueryBuilderMixin());
}

protected function aboutCommandInfo(): void
{
if (class_exists('Illuminate\Foundation\Console\AboutCommand')) {
AboutCommand::add('Feature Flags', [
'Pipeline' => fn () => implode(', Hello', config('features.pipeline')),
]);
}
}
}
15 changes: 15 additions & 0 deletions tests/FeatureFlagsServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace YlsIdeas\FeatureFlags\Tests;

use Illuminate\Foundation\Application;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
use Orchestra\Testbench\TestCase;
Expand Down Expand Up @@ -79,6 +80,20 @@ public function test_publishes_the_features_migration(): void
$this->assertNotNull($filename);
}

public function test_posting_about_info(): void
{
if (version_compare(Application::VERSION, '9.20.0', '<')) {
$this->markTestSkipped('Not available before Laravel 9.20.0');
}

config()->set('features.pipeline', ['in_memory']);

$this->artisan('about')
->expectsOutputToContain('Feature Flags')
->expectsOutputToContain('Pipeline')
->run();
}

protected function cleanUp(): void
{
File::delete(config_path('features.php'));
Expand Down

0 comments on commit 08a47dd

Please sign in to comment.