File tree Expand file tree Collapse file tree 3 files changed +13
-1
lines changed
test/Unit/StatementVersion Expand file tree Collapse file tree 3 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,9 @@ public function permitVersionStatement(): self
7676 {
7777 foreach ($ this ->flatten () as $ pipe ) {
7878 if (method_exists ($ pipe , 'permitted ' )) {
79+ if (is_string ($ pipe )) {
80+ $ pipe = new $ pipe ();
81+ }
7982 /** @var \ReindertVetter\ApiVersionControl\Concerns\VersionStatement $pipe */
8083 /** @noinspection PhpUndefinedFieldInspection */
8184 $ pipe ->permit = true ;
Original file line number Diff line number Diff line change @@ -25,8 +25,8 @@ public function __construct(array $config = null)
2525 public function handle (Request $ request , Closure $ next ): SymfonyResponse
2626 {
2727 $ pipes = MiddlewareCollection::createFromConfig ($ request , $ this ->config )
28- ->permitVersionStatement ()
2928 ->filterByVersionCompare ()
29+ ->permitVersionStatement ()
3030 ->flatten ()
3131 ->rejectNonPipe ()
3232 ->unique ()
Original file line number Diff line number Diff line change @@ -38,6 +38,15 @@ public function testNotPermitVersionStatement(): void
3838 $ this ->assertFalse (MockVersionStatementSecond::permitted ());
3939 }
4040
41+ public function testPermitVersionStatementStringClass (): void
42+ {
43+ $ goodVersionStatement = MockVersionStatementFirst::class;
44+ $ middlewareCollection = new MiddlewareCollection ([$ goodVersionStatement ]);
45+ $ middlewareCollection ->permitVersionStatement ();
46+
47+ $ this ->assertFalse (MockVersionStatementSecond::permitted ());
48+ }
49+
4150 public function testRejectVersionStatement (): void
4251 {
4352 $ middlewareCollection = new MiddlewareCollection (
You can’t perform that action at this time.
0 commit comments