8000 minor #13482 Implemented check on interface implementation (jaytaph) · symfony/symfony@1ba939f · GitHub
[go: up one dir, main page]

Skip to content

Commit 1ba939f

Browse files
committed
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
2 parents b9836b2 + 2a79ace commit 1ba939f

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