-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[SecurityBundle] Rename FirewallContext#getContext() #20417
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,17 @@ public function getConfig() | |
return $this->config; | ||
} | ||
|
||
/** | ||
* @deprecated since version 3.3, will be removed in 4.0. Use {@link getListeners()} instead. | ||
*/ | ||
public function getContext() | ||
{ | ||
@trigger_error(sprintf('Method %s() is deprecated since version 3.3 and will be removed in 4.0. Use %s::getListeners() instead.', __METHOD__, __CLASS__), E_USER_DEPRECATED); | ||
|
||
return $this->getListeners(); | ||
} | ||
|
||
public function getListeners() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a bit confusing considering that this returns both an array of listeners and an exception listener. |
||
{ | ||
return array($this->listeners, $this->exceptionListener); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,12 +21,7 @@ class FirewallContextTest extends \PHPUnit_Framework_TestCase | |
public function testGetters() | ||
{ | ||
$config = new FirewallConfig('main', 'user_checker', 'request_matcher'); | ||
|
||
$exceptionListener = $this | ||
->getMockBuilder(ExceptionListener::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$exceptionListener = $this->getExceptionListenerMock(); | ||
$listeners = array( | ||
$this | ||
->getMockBuilder(ListenerInterface::class) | ||
|
@@ -36,7 +31,25 @@ public function testGetters() | |
|
||
$context = new FirewallContext($listeners, $exceptionListener, $config); | ||
|
||
$this->assertEquals(array($listeners, $exceptionListener), $context->getContext()); | ||
$this->assertEquals(array($listeners, $exceptionListener), $context->getListeners()); | ||
$this->assertEquals($config, $context->getConfig()); | ||
} | ||
|
||
/** | ||
* @expectedDeprecation Method Symfony\Bundle\SecurityBundle\Security\FirewallContext::getContext() is deprecated since version 3.3 and will be removed in 4.0. Use Symfony\Bundle\SecurityBundle\Security\FirewallContext::getListeners() instead. | ||
* @group legacy | ||
*/ | ||
public function testGetContextTriggersDeprecation() | ||
{ | ||
(new FirewallContext(array(), $this->getExceptionListenerMock(), new FirewallConfig('main', 'request_matcher', 'user_checker'))) | ||
->getContext(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you should also assert the return value, to ensure that the BC layer works fine (returning null would make your test pass, but the class would be broken) |
||
} | ||
|
||
private function getExceptionListenerMock() | ||
{ | ||
return $this | ||
->getMockBuilder(ExceptionListener::class) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
} | ||
} |
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.
looks like this line could be wrapped to be in line with the other lines in the file