Skip to content

Commit

Permalink
Added "all" method to "EnsureFeaturesAreActive" middleware.
Browse files Browse the repository at this point in the history
  • Loading branch information
ash-jc-allen committed Aug 30, 2023
1 parent e22c3ae commit 4d3538c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Middleware/EnsureFeaturesAreActive.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ public static function whenInactive(?Closure $callback): void
{
static::$respondUsing = $callback;
}

public static function all(string ...$features): string
{
return static::class.':'.implode(',', $features);
}
}
8 changes: 8 additions & 0 deletions tests/Feature/FeatureMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ public function it_passes_if_all_features_are_enabled(): void
);
}

public function test_middleware_string_can_be_returned(): void
{
$this->assertEquals(
'Laravel\Pennant\Middleware\EnsureFeaturesAreActive:test,another',
EnsureFeaturesAreActive::all('test', 'another'),
);
}

protected function createRequest(string $uri, string $method): Request
{
$request = SymfonyRequest::create(
Expand Down

0 comments on commit 4d3538c

Please sign in to comment.