Implemented check on interface implementation
This commit is contained in:
parent
3d174a4058
commit
2a79ace826
@ -48,6 +48,12 @@ class AuthenticationProviderManager implements AuthenticationManagerInterface
|
||||
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->eraseCredentials = (bool) $eraseCredentials;
|
||||
}
|
||||
|
@ -27,6 +27,16 @@ class AuthenticationProviderManagerTest extends \PHPUnit_Framework_TestCase
|
||||
new AuthenticationProviderManager(array());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testAuthenticateWithProvidersWithIncorrectInterface()
|
||||
{
|
||||
new AuthenticationProviderManager(array(
|
||||
new \stdClass(),
|
||||
));
|
||||
}
|
||||
|
||||
public function testAuthenticateWhenNoProviderSupportsToken()
|
||||
{
|
||||
$manager = new AuthenticationProviderManager(array(
|
||||
|
Reference in New Issue
Block a user