diff options
Diffstat (limited to 'Core/Tests')
-rw-r--r-- | Core/Tests/Authentication/AuthenticationProviderManagerTest.php | 10 | ||||
-rw-r--r-- | Core/Tests/Encoder/BCryptPasswordEncoderTest.php | 11 | ||||
-rw-r--r-- | Core/Tests/LegacySecurityContextTest.php (renamed from Core/Tests/SecurityContextTest.php) | 7 | ||||
-rw-r--r-- | Core/Tests/User/UserTest.php | 9 | ||||
-rw-r--r-- | Core/Tests/Validator/Constraints/LegacyUserPasswordValidator2Dot4ApiTest.php | 27 | ||||
-rw-r--r-- | Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php | 16 |
6 files changed, 33 insertions, 47 deletions
diff --git a/Core/Tests/Authentication/AuthenticationProviderManagerTest.php b/Core/Tests/Authentication/AuthenticationProviderManagerTest.php index df25874..cc8b7c0 100644 --- a/Core/Tests/Authentication/AuthenticationProviderManagerTest.php +++ b/Core/Tests/Authentication/AuthenticationProviderManagerTest.php @@ -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( diff --git a/Core/Tests/Encoder/BCryptPasswordEncoderTest.php b/Core/Tests/Encoder/BCryptPasswordEncoderTest.php index 2f7b845..4d9ca6d 100644 --- a/Core/Tests/Encoder/BCryptPasswordEncoderTest.php +++ b/Core/Tests/Encoder/BCryptPasswordEncoderTest.php @@ -47,8 +47,6 @@ class BCryptPasswordEncoderTest extends \PHPUnit_Framework_TestCase public function testResultLength() { - $this->skipIfPhpVersionIsNotSupported(); - $encoder = new BCryptPasswordEncoder(self::VALID_COST); $result = $encoder->encodePassword(self::PASSWORD, null); $this->assertEquals(60, strlen($result)); @@ -56,21 +54,12 @@ class BCryptPasswordEncoderTest extends \PHPUnit_Framework_TestCase public function testValidation() { - $this->skipIfPhpVersionIsNotSupported(); - $encoder = new BCryptPasswordEncoder(self::VALID_COST); $result = $encoder->encodePassword(self::PASSWORD, null); $this->assertTrue($encoder->isPasswordValid($result, self::PASSWORD, null)); $this->assertFalse($encoder->isPasswordValid($result, 'anotherPassword', null)); } - private function skipIfPhpVersionIsNotSupported() - { - if (PHP_VERSION_ID < 50307) { - $this->markTestSkipped('Requires PHP >= 5.3.7'); - } - } - /** * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException */ diff --git a/Core/Tests/SecurityContextTest.php b/Core/Tests/LegacySecurityContextTest.php index bcf9ad9..f1f7861 100644 --- a/Core/Tests/SecurityContextTest.php +++ b/Core/Tests/LegacySecurityContextTest.php @@ -15,7 +15,10 @@ use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; use Symfony\Component\Security\Core\Authorization\AuthorizationChecker; use Symfony\Component\Security\Core\SecurityContext; -class SecurityContextTest extends \PHPUnit_Framework_TestCase +/** + * @group legacy + */ +class LegacySecurityContextTest extends \PHPUnit_Framework_TestCase { private $tokenStorage; private $authorizationChecker; @@ -23,6 +26,8 @@ class SecurityContextTest extends \PHPUnit_Framework_TestCase protected function setUp() { + $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); + $this->tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); $this->authorizationChecker = $this->getMock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'); $this->securityContext = new SecurityContext($this->tokenStorage, $this->authorizationChecker); diff --git a/Core/Tests/User/UserTest.php b/Core/Tests/User/UserTest.php index 2fe6daa..f514eda 100644 --- a/Core/Tests/User/UserTest.php +++ b/Core/Tests/User/UserTest.php @@ -123,4 +123,13 @@ class UserTest extends \PHPUnit_Framework_TestCase $user->eraseCredentials(); $this->assertEquals('superpass', $user->getPassword()); } + + /** + * @covers Symfony\Component\Security\Core\User\User::__toString + */ + public function testToString() + { + $user = new User('fabien', 'superpass'); + $this->assertEquals('fabien', (string) $user); + } } diff --git a/Core/Tests/Validator/Constraints/LegacyUserPasswordValidator2Dot4ApiTest.php b/Core/Tests/Validator/Constraints/LegacyUserPasswordValidator2Dot4ApiTest.php deleted file mode 100644 index cfbfdc1..0000000 --- a/Core/Tests/Validator/Constraints/LegacyUserPasswordValidator2Dot4ApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php - -/* - * This file is part of the Symfony package. - * - * (c) Fabien Potencier <fabien@symfony.com> - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Core\Tests\Validator\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.4 - * @author Bernhard Schussek <bschussek@gmail.com> - * @group legacy - */ -class LegacyUserPasswordValidator2Dot4ApiTest extends UserPasswordValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_4; - } -} diff --git a/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php b/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php index 7792913..047c929 100644 --- a/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php +++ b/Core/Tests/Validator/Constraints/UserPasswordValidatorTest.php @@ -11,9 +11,9 @@ namespace Symfony\Component\Security\Core\Tests\Validator\Constraints; +use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface; use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface; -use Symfony\Component\Security\Core\SecurityContextInterface; use Symfony\Component\Security\Core\Validator\Constraints\UserPassword; use Symfony\Component\Security\Core\Validator\Constraints\UserPasswordValidator; use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest; @@ -28,9 +28,9 @@ abstract class UserPasswordValidatorTest extends AbstractConstraintValidatorTest const SALT = '^S4lt$'; /** - * @var SecurityContextInterface + * @var TokenStorageInterface */ - protected $securityContext; + protected $tokenStorage; /** * @var PasswordEncoderInterface @@ -44,13 +44,13 @@ abstract class UserPasswordValidatorTest extends AbstractConstraintValidatorTest protected function createValidator() { - return new UserPasswordValidator($this->securityContext, $this->encoderFactory); + return new UserPasswordValidator($this->tokenStorage, $this->encoderFactory); } protected function setUp() { $user = $this->createUser(); - $this->securityContext = $this->createSecurityContext($user); + $this->tokenStorage = $this->createTokenStorage($user); $this->encoder = $this->createPasswordEncoder(); $this->encoderFactory = $this->createEncoderFactory($this->encoder); @@ -97,7 +97,7 @@ abstract class UserPasswordValidatorTest extends AbstractConstraintValidatorTest { $user = $this->getMock('Foo\Bar\User'); - $this->securityContext = $this->createSecurityContext($user); + $this->tokenStorage = $this->createTokenStorage($user); $this->validator = $this->createValidator(); $this->validator->initialize($this->context); @@ -141,11 +141,11 @@ abstract class UserPasswordValidatorTest extends AbstractConstraintValidatorTest return $mock; } - protected function createSecurityContext($user = null) + protected function createTokenStorage($user = null) { $token = $this->createAuthenticationToken($user); - $mock = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'); + $mock = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); $mock ->expects($this->any()) ->method('getToken') |