summaryrefslogtreecommitdiffstats
path: root/Core/Tests/LegacySecurityContextTest.php
diff options
context:
space:
mode:
authorNicolas Grekas <nicolas.grekas@gmail.com>2015-09-03 21:29:24 +0200
committerNicolas Grekas <nicolas.grekas@gmail.com>2015-09-03 21:48:11 +0200
commit12610e011217e0913724983d5c5297624577d4d1 (patch)
treefef452b9f6ebb2ad054d08527d36be6a78a96c4f /Core/Tests/LegacySecurityContextTest.php
parentcbeb4cecfc7efa6aae465a83b02e943545140fbf (diff)
downloadsymfony-security-12610e011217e0913724983d5c5297624577d4d1.zip
symfony-security-12610e011217e0913724983d5c5297624577d4d1.tar.gz
symfony-security-12610e011217e0913724983d5c5297624577d4d1.tar.bz2
[Security] Remove deprecated interfaces
Diffstat (limited to 'Core/Tests/LegacySecurityContextTest.php')
-rw-r--r--Core/Tests/LegacySecurityContextTest.php122
1 files changed, 0 insertions, 122 deletions
diff --git a/Core/Tests/LegacySecurityContextTest.php b/Core/Tests/LegacySecurityContextTest.php
deleted file mode 100644
index 92d7c16..0000000
--- a/Core/Tests/LegacySecurityContextTest.php
+++ /dev/null
@@ -1,122 +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\Authentication\Token\Storage\TokenStorage;
-use Symfony\Component\Security\Core\Authorization\AuthorizationChecker;
-use Symfony\Component\Security\Core\SecurityContext;
-
-/**
- * @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),
- );
- }
-}