|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Component\Security\Guard\Tests\Authenticator; |
| 13 | + |
| 14 | +use Symfony\Component\HttpFoundation\RedirectResponse; |
| 15 | +use Symfony\Component\HttpFoundation\Request; |
| 16 | +use Symfony\Component\Security\Core\User\UserInterface; |
| 17 | +use Symfony\Component\Security\Core\User\UserProviderInterface; |
| 18 | +use Symfony\Component\Security\Guard\Authenticator\AbstractFormLoginAuthenticator; |
| 19 | + |
| 20 | +class AbstractFormLoginAuthenticatorTest extends \PHPUnit_Framework_TestCase |
| 21 | +{ |
| 22 | + /** |
| 23 | + * @group legacy |
| 24 | + */ |
| 25 | + public function testLegacyWithLoginUrl() |
| 26 | + { |
| 27 | + $request = new Request(); |
| 28 | + $request->setSession($this->getMock('Symfony\Component\HttpFoundation\Session\Session')); |
| 29 | + |
| 30 | + $authenticator = new LegacyFormLoginAuthenticator(); |
| 31 | + /** @var RedirectResponse $actualResponse */ |
| 32 | + $actualResponse = $authenticator->onAuthenticationSuccess( |
| 33 | + $request, |
| 34 | + $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'), |
| 35 | + 'provider_key' |
| 36 | + ); |
| 37 | + |
| 38 | + $this->assertEquals('/default_url', $actualResponse->getTargetUrl()); |
| 39 | + } |
| 40 | +} |
| 41 | + |
| 42 | +class LegacyFormLoginAuthenticator extends AbstractFormLoginAuthenticator |
| 43 | +{ |
| 44 | + protected function getDefaultSuccessRedirectUrl() |
| 45 | + { |
| 46 | + return '/default_url'; |
| 47 | + } |
| 48 | + |
| 49 | + protected function getLoginUrl() |
| 50 | + { |
| 51 | + } |
| 52 | + |
| 53 | + public function getCredentials(Request $request) |
| 54 | + { |
| 55 | + } |
| 56 | + |
| 57 | + public function getUser($credentials, UserProviderInterface $userProvider) |
| 58 | + { |
| 59 | + } |
| 60 | + |
| 61 | + public function checkCredentials($credentials, UserInterface $user) |
| 62 | + { |
| 63 | + } |
| 64 | +} |
0 commit comments