-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] check _controller attribute is a string before parsing it #23457
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
Conversation
@@ -51,4 +51,23 @@ public function testSkipsOtherControllerFormats() | |||
$subscriber->onKernelRequest(new GetResponseEvent($httpKernel, $request, HttpKernelInterface::MASTER_REQUEST)); | |||
$this->assertEquals('Other:format', $request->attributes->get('_controller')); | |||
} | |||
|
|||
public function testSkipsNonStringControllers() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alekitto, you could use the data provider to avoid a code duplication. Like this:
/** @dataProvider provideSkippedControllers */
public function testSkipsOtherControllerFormats($controller)
{
// ...
$this->assertEquals($controller, $request->attributes->get('_controller'));
}
private function provideSkippedControllers()
{
yield [ 'Other:format' ];
yield [ function() {} ];
}
c7385cc
to
7f0da59
Compare
@voronkovich Ok, i've added a data provider for this test as requested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 with minor comment
@@ -37,18 +37,27 @@ public function testReplacesControllerAttribute() | |||
$this->assertEquals('App\\Final\\Format::methodName', $request->attributes->get('_controller')); | |||
} | |||
|
|||
public function testSkipsOtherControllerFormats() | |||
public function provideSkippedControllers() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please move it below the test case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Thank you @alekitto. |
…before parsing it (alekitto) This PR was merged into the 3.3 branch. Discussion ---------- [FrameworkBundle] check _controller attribute is a string before parsing it | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #23456 | License | MIT Avoids an error to be raised in case described in issue #23456. Commits ------- 0b349ae check _controller attribute is a string before parsing it
Avoids an error to be raised in case described in issue #23456.