8000 Implemented check on interface implementation · symfony/symfony@2a79ace · GitHub
[go: up one dir, main page]

Skip to content

Commit 2a79ace

Browse files
jaytaphfabpot
authored andcommitted
Implemented check on interface implementation
1 parent 3d174a4 commit 2a79ace

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/Symfony/Component/Security/Core/Authentication/AuthenticationProviderManager.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ public function __construct(array $providers, $eraseCredentials = true)
4848
throw new \InvalidArgumentException('You must at least add one authentication provider.');
4949
}
5050

51+
foreach ($providers as $provider) {
52+
if (!$provider instanceof AuthenticationProviderInterface) {
53+
throw new \InvalidArgumentException(sprintf('Provider "%s" must implement the AuthenticationProviderInterface.', get_class($provider)));
54+
}
55+
}
56+
5157
$this->providers = $providers;
5258
$this->eraseCredentials = (bool) $eraseCredentials;
5359
}

src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ public function testAuthenticateWithoutProviders()
2727
new AuthenticationProviderManager(array());
2828
}
2929

30+
/**
31+
* @expectedException \InvalidArgumentException
32+
*/
33+
public function testAuthenticateWithProvidersWithIncorrectInterface()
34+
{
35+
new AuthenticationProviderManager(array(
36+
new \stdClass(),
37+
));
38+
}
39+
3040
public function testAuthenticateWhenNoProviderSupportsToken()
3141
{
3242
$manager = new AuthenticationProviderManager(array(

0 commit comments

Comments
 (0)
0