diff options
Diffstat (limited to 'Core/Tests')
-rw-r--r-- | Core/Tests/Authorization/AccessDecisionManagerTest.php | 56 | ||||
-rw-r--r-- | Core/Tests/Authorization/Voter/AbstractVoterTest.php | 58 | ||||
-rw-r--r-- | Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php | 6 | ||||
-rw-r--r-- | Core/Tests/Authorization/Voter/ExpressionVoterTest.php | 9 | ||||
-rw-r--r-- | Core/Tests/Authorization/Voter/Fixtures/MyVoter.php | 27 | ||||
-rw-r--r-- | Core/Tests/Authorization/Voter/RoleVoterTest.php | 7 | ||||
-rw-r--r-- | Core/Tests/LegacySecurityContextTest.php | 132 | ||||
-rw-r--r-- | Core/Tests/Util/ClassUtilsTest.php | 53 | ||||
-rw-r--r-- | Core/Tests/Util/StringUtilsTest.php | 63 | ||||
-rw-r--r-- | Core/Tests/Validator/Constraints/LegacyUserPasswordValidatorTest.php | 28 |
10 files changed, 0 insertions, 439 deletions
diff --git a/Core/Tests/Authorization/AccessDecisionManagerTest.php b/Core/Tests/Authorization/AccessDecisionManagerTest.php index 412af91..0e77c75 100644 --- a/Core/Tests/Authorization/AccessDecisionManagerTest.php +++ b/Core/Tests/Authorization/AccessDecisionManagerTest.php @@ -17,42 +17,6 @@ use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; class AccessDecisionManagerTest extends \PHPUnit_Framework_TestCase { /** - * @group legacy - */ - public function testSupportsClass() - { - $manager = new AccessDecisionManager(array( - $this->getVoterSupportsClass(true), - $this->getVoterSupportsClass(false), - )); - $this->assertTrue($manager->supportsClass('FooClass')); - - $manager = new AccessDecisionManager(array( - $this->getVoterSupportsClass(false), - $this->getVoterSupportsClass(false), - )); - $this->assertFalse($manager->supportsClass('FooClass')); - } - - /** - * @group legacy - */ - public function testSupportsAttribute() - { - $manager = new AccessDecisionManager(array( - $this->getVoterSupportsAttribute(true), - $this->getVoterSupportsAttribute(false), - )); - $this->assertTrue($manager->supportsAttribute('foo')); - - $manager = new AccessDecisionManager(array( - $this->getVoterSupportsAttribute(false), - $this->getVoterSupportsAttribute(false), - )); - $this->assertFalse($manager->supportsAttribute('foo')); - } - - /** * @expectedException \InvalidArgumentException */ public function testSetUnsupportedStrategy() @@ -173,24 +137,4 @@ class AccessDecisionManagerTest extends \PHPUnit_Framework_TestCase return $voter; } - - protected function getVoterSupportsClass($ret) - { - $voter = $this->getMock('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface'); - $voter->expects($this->any()) - ->method('supportsClass') - ->will($this->returnValue($ret)); - - return $voter; - } - - protected function getVoterSupportsAttribute($ret) - { - $voter = $this->getMock('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface'); - $voter->expects($this->any()) - ->method('supportsAttribute') - ->will($this->returnValue($ret)); - - return $voter; - } } diff --git a/Core/Tests/Authorization/Voter/AbstractVoterTest.php b/Core/Tests/Authorization/Voter/AbstractVoterTest.php deleted file mode 100644 index b537c1b..0000000 --- a/Core/Tests/Authorization/Voter/AbstractVoterTest.php +++ /dev/null @@ -1,58 +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\Authorization\Voter; - -use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; - -/** - * @group legacy - */ -class AbstractVoterTest extends \PHPUnit_Framework_TestCase -{ - protected $token; - - protected function setUp() - { - $this->token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); - } - - public function getTests() - { - return array( - array(array('EDIT'), VoterInterface::ACCESS_GRANTED, new \stdClass(), 'ACCESS_GRANTED if attribute and class are supported and attribute grants access'), - array(array('CREATE'), VoterInterface::ACCESS_DENIED, new \stdClass(), 'ACCESS_DENIED if attribute and class are supported and attribute does not grant access'), - - array(array('DELETE', 'EDIT'), VoterInterface::ACCESS_GRANTED, new \stdClass(), 'ACCESS_GRANTED if one attribute is supported and grants access'), - array(array('DELETE', 'CREATE'), VoterInterface::ACCESS_DENIED, new \stdClass(), 'ACCESS_DENIED if one attribute is supported and denies access'), - - array(array('CREATE', 'EDIT'), VoterInterface::ACCESS_GRANTED, new \stdClass(), 'ACCESS_GRANTED if one attribute grants access'), - - array(array('DELETE'), VoterInterface::ACCESS_ABSTAIN, new \stdClass(), 'ACCESS_ABSTAIN if no attribute is supported'), - - array(array('EDIT'), VoterInterface::ACCESS_ABSTAIN, $this, 'ACCESS_ABSTAIN if class is not supported'), - - array(array('EDIT'), VoterInterface::ACCESS_ABSTAIN, null, 'ACCESS_ABSTAIN if object is null'), - - array(array(), VoterInterface::ACCESS_ABSTAIN, new \stdClass(), 'ACCESS_ABSTAIN if no attributes were provided'), - ); - } - - /** - * @dataProvider getTests - */ - public function testVote(array $attributes, $expectedVote, $object, $message) - { - $voter = new Fixtures\MyVoter(); - - $this->assertEquals($expectedVote, $voter->vote($this->token, $object, $attributes), $message); - } -} diff --git a/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php b/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php index 4679c0f..60e2a19 100644 --- a/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php +++ b/Core/Tests/Authorization/Voter/AuthenticatedVoterTest.php @@ -17,12 +17,6 @@ use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface; class AuthenticatedVoterTest extends \PHPUnit_Framework_TestCase { - public function testSupportsClass() - { - $voter = new AuthenticatedVoter($this->getResolver()); - $this->assertTrue($voter->supportsClass('stdClass')); - } - /** * @dataProvider getVoteTests */ diff --git a/Core/Tests/Authorization/Voter/ExpressionVoterTest.php b/Core/Tests/Authorization/Voter/ExpressionVoterTest.php index dc8ea79..5296296 100644 --- a/Core/Tests/Authorization/Voter/ExpressionVoterTest.php +++ b/Core/Tests/Authorization/Voter/ExpressionVoterTest.php @@ -17,15 +17,6 @@ use Symfony\Component\Security\Core\Role\Role; class ExpressionVoterTest extends \PHPUnit_Framework_TestCase { - public function testSupportsAttribute() - { - $expression = $this->createExpression(); - $expressionLanguage = $this->getMock('Symfony\Component\Security\Core\Authorization\ExpressionLanguage'); - $voter = new ExpressionVoter($expressionLanguage, $this->createTrustResolver(), $this->createRoleHierarchy()); - - $this->assertTrue($voter->supportsAttribute($expression)); - } - /** * @dataProvider getVoteTests */ diff --git a/Core/Tests/Authorization/Voter/Fixtures/MyVoter.php b/Core/Tests/Authorization/Voter/Fixtures/MyVoter.php deleted file mode 100644 index b75f798..0000000 --- a/Core/Tests/Authorization/Voter/Fixtures/MyVoter.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php - -namespace Symfony\Component\Security\Core\Tests\Authorization\Voter\Fixtures; - -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; -use Symfony\Component\Security\Core\Authorization\Voter\AbstractVoter; - -/** - * @group legacy - */ -class MyVoter extends AbstractVoter -{ - protected function getSupportedClasses() - { - return array('stdClass'); - } - - protected function getSupportedAttributes() - { - return array('EDIT', 'CREATE'); - } - - protected function isGranted($attribute, $object, $user = null) - { - return 'EDIT' === $attribute; - } -} diff --git a/Core/Tests/Authorization/Voter/RoleVoterTest.php b/Core/Tests/Authorization/Voter/RoleVoterTest.php index 03ab2da..9982bdf 100644 --- a/Core/Tests/Authorization/Voter/RoleVoterTest.php +++ b/Core/Tests/Authorization/Voter/RoleVoterTest.php @@ -17,13 +17,6 @@ use Symfony\Component\Security\Core\Role\Role; class RoleVoterTest extends \PHPUnit_Framework_TestCase { - public function testSupportsClass() - { - $voter = new RoleVoter(); - - $this->assertTrue($voter->supportsClass('Foo')); - } - /** * @dataProvider getVoteTests */ diff --git a/Core/Tests/LegacySecurityContextTest.php b/Core/Tests/LegacySecurityContextTest.php deleted file mode 100644 index 4502261..0000000 --- a/Core/Tests/LegacySecurityContextTest.php +++ /dev/null @@ -1,132 +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; - -use Symfony\Component\Security\Core\Security; -use Symfony\Component\Security\Core\SecurityContext; -use Symfony\Component\Security\Core\SecurityContextInterface; - -/** - * @group legacy - */ -class LegacySecurityContextTest extends \PHPUnit_Framework_TestCase -{ - private $tokenStorage; - private $authorizationChecker; - private $securityContext; - - protected function setUp() - { - $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); - } - - public function testGetTokenDelegation() - { - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); - - $this->tokenStorage - ->expects($this->once()) - ->method('getToken') - ->will($this->returnValue($token)); - - $this->assertTrue($token === $this->securityContext->getToken()); - } - - public function testSetTokenDelegation() - { - $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); - - $this->tokenStorage - ->expects($this->once()) - ->method('setToken') - ->with($token); - - $this->securityContext->setToken($token); - } - - /** - * @dataProvider isGrantedDelegationProvider - */ - public function testIsGrantedDelegation($attributes, $object, $return) - { - $this->authorizationChecker - ->expects($this->once()) - ->method('isGranted') - ->with($attributes, $object) - ->will($this->returnValue($return)); - - $this->assertEquals($return, $this->securityContext->isGranted($attributes, $object)); - } - - public function isGrantedDelegationProvider() - { - return array( - array(array(), new \stdClass(), true), - array(array('henk'), new \stdClass(), false), - array(null, new \stdClass(), false), - array('henk', null, true), - array(array(1), 'henk', true), - ); - } - - /** - * Test dedicated to check if the backwards compatibility is still working. - */ - public function testOldConstructorSignature() - { - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); - $accessDecisionManager = $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface'); - new SecurityContext($authenticationManager, $accessDecisionManager); - } - - /** - * @dataProvider oldConstructorSignatureFailuresProvider - * @expectedException \BadMethodCallException - */ - public function testOldConstructorSignatureFailures($first, $second) - { - new SecurityContext($first, $second); - } - - public function oldConstructorSignatureFailuresProvider() - { - $tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'); - $authorizationChecker = $this->getMock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'); - $authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface'); - $accessDecisionManager = $this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface'); - - return array( - array(new \stdClass(), new \stdClass()), - array($tokenStorage, $accessDecisionManager), - array($accessDecisionManager, $tokenStorage), - array($authorizationChecker, $accessDecisionManager), - array($accessDecisionManager, $authorizationChecker), - array($tokenStorage, $accessDecisionManager), - array($authenticationManager, $authorizationChecker), - array('henk', 'hans'), - array(null, false), - array(true, null), - ); - } - - /** - * Test if the BC Layer is working as intended. - */ - public function testConstantSync() - { - $this->assertSame(Security::ACCESS_DENIED_ERROR, SecurityContextInterface::ACCESS_DENIED_ERROR); - $this->assertSame(Security::AUTHENTICATION_ERROR, SecurityContextInterface::AUTHENTICATION_ERROR); - $this->assertSame(Security::LAST_USERNAME, SecurityContextInterface::LAST_USERNAME); - } -} diff --git a/Core/Tests/Util/ClassUtilsTest.php b/Core/Tests/Util/ClassUtilsTest.php deleted file mode 100644 index b048206..0000000 --- a/Core/Tests/Util/ClassUtilsTest.php +++ /dev/null @@ -1,53 +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\Util -{ - use Symfony\Component\Security\Core\Util\ClassUtils; - - /** - * @group legacy - */ - class ClassUtilsTest extends \PHPUnit_Framework_TestCase - { - public static function dataGetClass() - { - return array( - array('stdClass', 'stdClass'), - array('Symfony\Component\Security\Core\Util\ClassUtils', 'Symfony\Component\Security\Core\Util\ClassUtils'), - array('MyProject\Proxies\__CG__\stdClass', 'stdClass'), - array('MyProject\Proxies\__CG__\OtherProject\Proxies\__CG__\stdClass', 'stdClass'), - array('MyProject\Proxies\__CG__\Symfony\Component\Security\Core\Tests\Util\ChildObject', 'Symfony\Component\Security\Core\Tests\Util\ChildObject'), - array(new TestObject(), 'Symfony\Component\Security\Core\Tests\Util\TestObject'), - array(new \Acme\DemoBundle\Proxy\__CG__\Symfony\Component\Security\Core\Tests\Util\TestObject(), 'Symfony\Component\Security\Core\Tests\Util\TestObject'), - ); - } - - /** - * @dataProvider dataGetClass - */ - public function testGetRealClass($object, $expectedClassName) - { - $this->assertEquals($expectedClassName, ClassUtils::getRealClass($object)); - } - } - - class TestObject - { - } -} - -namespace Acme\DemoBundle\Proxy\__CG__\Symfony\Component\Security\Core\Tests\Util -{ - class TestObject extends \Symfony\Component\Security\Core\Tests\Util\TestObject - { - } -} diff --git a/Core/Tests/Util/StringUtilsTest.php b/Core/Tests/Util/StringUtilsTest.php deleted file mode 100644 index 78d9b05..0000000 --- a/Core/Tests/Util/StringUtilsTest.php +++ /dev/null @@ -1,63 +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\Util; - -use Symfony\Component\Security\Core\Util\StringUtils; - -/** - * Data from PHP.net's hash_equals tests. - * - * @group legacy - */ -class StringUtilsTest extends \PHPUnit_Framework_TestCase -{ - public function dataProviderTrue() - { - return array( - array('same', 'same'), - array('', ''), - array(123, 123), - array(null, ''), - array(null, null), - ); - } - - public function dataProviderFalse() - { - return array( - array('not1same', 'not2same'), - array('short', 'longer'), - array('longer', 'short'), - array('', 'notempty'), - array('notempty', ''), - array(123, 'NaN'), - array('NaN', 123), - array(null, 123), - ); - } - - /** - * @dataProvider dataProviderTrue - */ - public function testEqualsTrue($known, $user) - { - $this->assertTrue(StringUtils::equals($known, $user)); - } - - /** - * @dataProvider dataProviderFalse - */ - public function testEqualsFalse($known, $user) - { - $this->assertFalse(StringUtils::equals($known, $user)); - } -} diff --git a/Core/Tests/Validator/Constraints/LegacyUserPasswordValidatorTest.php b/Core/Tests/Validator/Constraints/LegacyUserPasswordValidatorTest.php deleted file mode 100644 index 8053732..0000000 --- a/Core/Tests/Validator/Constraints/LegacyUserPasswordValidatorTest.php +++ /dev/null @@ -1,28 +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 LegacyUserPasswordValidatorTest extends UserPasswordValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} |