minor #13482 Implemented check on interface implementation (jaytaph)
This PR was squashed before being merged into the 2.7 branch (closes #13482).
Discussion
----------
Implemented check on interface implementation
| Q | A
| ------------- | ---
| Bug fix? | Yes
| New feature? | No
| BC breaks? | No
| Deprecations? | No
| Tests pass? | Yes
| Fixed tickets | #13480
| License | MIT
| Doc PR |
Commits
-------
2a79ace
Implemented check on interface implementation
This commit is contained in:
commit
1ba939f2e6
@ -48,6 +48,12 @@ class AuthenticationProviderManager implements AuthenticationManagerInterface
|
|||||||
throw new \InvalidArgumentException('You must at least add one authentication provider.');
|
throw new \InvalidArgumentException('You must at least add one authentication provider.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($providers as $provider) {
|
||||||
|
if (!$provider instanceof AuthenticationProviderInterface) {
|
||||||
|
throw new \InvalidArgumentException(sprintf('Provider "%s" must implement the AuthenticationProviderInterface.', get_class($provider)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->providers = $providers;
|
$this->providers = $providers;
|
||||||
$this->eraseCredentials = (bool) $eraseCredentials;
|
$this->eraseCredentials = (bool) $eraseCredentials;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,16 @@ class AuthenticationProviderManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
new AuthenticationProviderManager(array());
|
new AuthenticationProviderManager(array());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function testAuthenticateWithProvidersWithIncorrectInterface()
|
||||||
|
{
|
||||||
|
new AuthenticationProviderManager(array(
|
||||||
|
new \stdClass(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
public function testAuthenticateWhenNoProviderSupportsToken()
|
public function testAuthenticateWhenNoProviderSupportsToken()
|
||||||
{
|
{
|
||||||
$manager = new AuthenticationProviderManager(array(
|
$manager = new AuthenticationProviderManager(array(
|
||||||
|
Reference in New Issue
Block a user