summaryrefslogtreecommitdiffstats
path: root/Core/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'Core/Tests')
-rw-r--r--Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php18
-rw-r--r--Core/Tests/Authorization/AccessDecisionManagerTest.php8
-rw-r--r--Core/Tests/Authorization/DebugAccessDecisionManagerTest.php2
-rw-r--r--Core/Tests/Authorization/Voter/ExpressionVoterTest.php8
-rw-r--r--Core/Tests/User/LdapUserProviderTest.php38
5 files changed, 37 insertions, 37 deletions
diff --git a/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php b/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php
index da3068f..9359f86 100644
--- a/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php
+++ b/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php
@@ -30,9 +30,9 @@ class LdapBindAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testEmptyPasswordShouldThrowAnException()
{
- $userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface');
- $ldap = $this->getMock('Symfony\Component\Ldap\LdapClientInterface');
- $userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
+ $userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock();
+ $ldap = $this->getMockBuilder('Symfony\Component\Ldap\LdapClientInterface')->getMock();
+ $userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
$provider = new LdapBindAuthenticationProvider($userProvider, $userChecker, 'key', $ldap);
$reflection = new \ReflectionMethod($provider, 'checkAuthentication');
@@ -47,14 +47,14 @@ class LdapBindAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testBindFailureShouldThrowAnException()
{
- $userProvider = $this->getMock(UserProviderInterface::class);
- $ldap = $this->getMock(LdapInterface::class);
+ $userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock();
+ $ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$ldap
->expects($this->once())
->method('bind')
->will($this->throwException(new ConnectionException()))
;
- $userChecker = $this->getMock(UserCheckerInterface::class);
+ $userChecker = $this->getMockBuilder(UserCheckerInterface::class)->getMock();
$provider = new LdapBindAuthenticationProvider($userProvider, $userChecker, 'key', $ldap);
$reflection = new \ReflectionMethod($provider, 'checkAuthentication');
@@ -65,15 +65,15 @@ class LdapBindAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
public function testRetrieveUser()
{
- $userProvider = $this->getMock(UserProviderInterface::class);
+ $userProvider = $this->getMockBuilder(UserProviderInterface::class)->getMock();
$userProvider
->expects($this->once())
->method('loadUserByUsername')
->with('foo')
;
- $ldap = $this->getMock(LdapInterface::class);
+ $ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
- $userChecker = $this->getMock(UserCheckerInterface::class);
+ $userChecker = $this->getMockBuilder(UserCheckerInterface::class)->getMock();
$provider = new LdapBindAuthenticationProvider($userProvider, $userChecker, 'key', $ldap);
$reflection = new \ReflectionMethod($provider, 'retrieveUser');
diff --git a/Core/Tests/Authorization/AccessDecisionManagerTest.php b/Core/Tests/Authorization/AccessDecisionManagerTest.php
index 0e77c75..8aace21 100644
--- a/Core/Tests/Authorization/AccessDecisionManagerTest.php
+++ b/Core/Tests/Authorization/AccessDecisionManagerTest.php
@@ -29,7 +29,7 @@ class AccessDecisionManagerTest extends \PHPUnit_Framework_TestCase
*/
public function testStrategies($strategy, $voters, $allowIfAllAbstainDecisions, $allowIfEqualGrantedDeniedDecisions, $expected)
{
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$manager = new AccessDecisionManager($voters, $strategy, $allowIfAllAbstainDecisions, $allowIfEqualGrantedDeniedDecisions);
$this->assertSame($expected, $manager->decide($token, array('ROLE_FOO')));
@@ -47,7 +47,7 @@ class AccessDecisionManagerTest extends \PHPUnit_Framework_TestCase
public function getStrategiesWith2RolesTests()
{
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
return array(
array($token, 'affirmative', $this->getVoter(VoterInterface::ACCESS_DENIED), false),
@@ -65,7 +65,7 @@ class AccessDecisionManagerTest extends \PHPUnit_Framework_TestCase
protected function getVoterFor2Roles($token, $vote1, $vote2)
{
- $voter = $this->getMock('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface');
+ $voter = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface')->getMock();
$voter->expects($this->any())
->method('vote')
->will($this->returnValueMap(array(
@@ -130,7 +130,7 @@ class AccessDecisionManagerTest extends \PHPUnit_Framework_TestCase
protected function getVoter($vote)
{
- $voter = $this->getMock('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface');
+ $voter = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\Voter\VoterInterface')->getMock();
$voter->expects($this->any())
->method('vote')
->will($this->returnValue($vote));
diff --git a/Core/Tests/Authorization/DebugAccessDecisionManagerTest.php b/Core/Tests/Authorization/DebugAccessDecisionManagerTest.php
index f90f776..bbca8ba 100644
--- a/Core/Tests/Authorization/DebugAccessDecisionManagerTest.php
+++ b/Core/Tests/Authorization/DebugAccessDecisionManagerTest.php
@@ -23,7 +23,7 @@ class DebugAccessDecisionManagerTest extends \PHPUnit_Framework_TestCase
public function testDecideLog($expectedLog, $object)
{
$adm = new DebugAccessDecisionManager(new AccessDecisionManager());
- $adm->decide($this->getMock(TokenInterface::class), array('ATTRIBUTE_1'), $object);
+ $adm->decide($this->getMockBuilder(TokenInterface::class)->getMock(), array('ATTRIBUTE_1'), $object);
$this->assertSame($expectedLog, $adm->getDecisionLog());
}
diff --git a/Core/Tests/Authorization/Voter/ExpressionVoterTest.php b/Core/Tests/Authorization/Voter/ExpressionVoterTest.php
index 5296296..714e6a0 100644
--- a/Core/Tests/Authorization/Voter/ExpressionVoterTest.php
+++ b/Core/Tests/Authorization/Voter/ExpressionVoterTest.php
@@ -45,7 +45,7 @@ class ExpressionVoterTest extends \PHPUnit_Framework_TestCase
foreach ($roles as $i => $role) {
$roles[$i] = new Role($role);
}
- $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
+ $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
if ($tokenExpectsGetRoles) {
$token->expects($this->once())
@@ -58,7 +58,7 @@ class ExpressionVoterTest extends \PHPUnit_Framework_TestCase
protected function createExpressionLanguage($expressionLanguageExpectsEvaluate = true)
{
- $mock = $this->getMock('Symfony\Component\Security\Core\Authorization\ExpressionLanguage');
+ $mock = $this->getMockBuilder('Symfony\Component\Security\Core\Authorization\ExpressionLanguage')->getMock();
if ($expressionLanguageExpectsEvaluate) {
$mock->expects($this->once())
@@ -71,12 +71,12 @@ class ExpressionVoterTest extends \PHPUnit_Framework_TestCase
protected function createTrustResolver()
{
- return $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface');
+ return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface')->getMock();
}
protected function createRoleHierarchy()
{
- return $this->getMock('Symfony\Component\Security\Core\Role\RoleHierarchyInterface');
+ return $this->getMockBuilder('Symfony\Component\Security\Core\Role\RoleHierarchyInterface')->getMock();
}
protected function createExpression()
diff --git a/Core/Tests/User/LdapUserProviderTest.php b/Core/Tests/User/LdapUserProviderTest.php
index b942e76..a1ef0bb 100644
--- a/Core/Tests/User/LdapUserProviderTest.php
+++ b/Core/Tests/User/LdapUserProviderTest.php
@@ -28,7 +28,7 @@ class LdapUserProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testLoadUserByUsernameFailsIfCantConnectToLdap()
{
- $ldap = $this->getMock(LdapInterface::class);
+ $ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$ldap
->expects($this->once())
->method('bind')
@@ -44,8 +44,8 @@ class LdapUserProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testLoadUserByUsernameFailsIfNoLdapEntries()
{
- $result = $this->getMock(CollectionInterface::class);
- $query = $this->getMock(QueryInterface::class);
+ $result = $this->getMockBuilder(CollectionInterface::class)->getMock();
+ $query = $this->getMockBuilder(QueryInterface::class)->getMock();
$query
->expects($this->once())
->method('execute')
@@ -56,7 +56,7 @@ class LdapUserProviderTest extends \PHPUnit_Framework_TestCase
->method('count')
->will($this->returnValue(0))
;
- $ldap = $this->getMock(LdapInterface::class);
+ $ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$ldap
->expects($this->once())
->method('escape')
@@ -77,8 +77,8 @@ class LdapUserProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testLoadUserByUsernameFailsIfMoreThanOneLdapEntry()
{
- $result = $this->getMock(CollectionInterface::class);
- $query = $this->getMock(QueryInterface::class);
+ $result = $this->getMockBuilder(CollectionInterface::class)->getMock();
+ $query = $this->getMockBuilder(QueryInterface::class)->getMock();
$query
->expects($this->once())
->method('execute')
@@ -89,7 +89,7 @@ class LdapUserProviderTest extends \PHPUnit_Framework_TestCase
->method('count')
->will($this->returnValue(2))
;
- $ldap = $this->getMock(LdapInterface::class);
+ $ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$ldap
->expects($this->once())
->method('escape')
@@ -110,14 +110,14 @@ class LdapUserProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testLoadUserByUsernameFailsIfMoreThanOneLdapPasswordsInEntry()
{
- $result = $this->getMock(CollectionInterface::class);
- $query = $this->getMock(QueryInterface::class);
+ $result = $this->getMockBuilder(CollectionInterface::class)->getMock();
+ $query = $this->getMockBuilder(QueryInterface::class)->getMock();
$query
->expects($this->once())
->method('execute')
->will($this->returnValue($result))
;
- $ldap = $this->getMock(LdapInterface::class);
+ $ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$result
->expects($this->once())
->method('offsetGet')
@@ -156,14 +156,14 @@ class LdapUserProviderTest extends \PHPUnit_Framework_TestCase
*/
public function testLoadUserByUsernameFailsIfEntryHasNoPasswordAttribute()
{
- $result = $this->getMock(CollectionInterface::class);
- $query = $this->getMock(QueryInterface::class);
+ $result = $this->getMockBuilder(CollectionInterface::class)->getMock();
+ $query = $this->getMockBuilder(QueryInterface::class)->getMock();
$query
->expects($this->once())
->method('execute')
->will($this->returnValue($result))
;
- $ldap = $this->getMock(LdapInterface::class);
+ $ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$result
->expects($this->once())
->method('offsetGet')
@@ -198,14 +198,14 @@ class LdapUserProviderTest extends \PHPUnit_Framework_TestCase
public function testLoadUserByUsernameIsSuccessfulWithoutPasswordAttribute()
{
- $result = $this->getMock(CollectionInterface::class);
- $query = $this->getMock(QueryInterface::class);
+ $result = $this->getMockBuilder(CollectionInterface::class)->getMock();
+ $query = $this->getMockBuilder(QueryInterface::class)->getMock();
$query
->expects($this->once())
->method('execute')
->will($this->returnValue($result))
;
- $ldap = $this->getMock(LdapInterface::class);
+ $ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$result
->expects($this->once())
->method('offsetGet')
@@ -240,14 +240,14 @@ class LdapUserProviderTest extends \PHPUnit_Framework_TestCase
public function testLoadUserByUsernameIsSuccessfulWithPasswordAttribute()
{
- $result = $this->getMock(CollectionInterface::class);
- $query = $this->getMock(QueryInterface::class);
+ $result = $this->getMockBuilder(CollectionInterface::class)->getMock();
+ $query = $this->getMockBuilder(QueryInterface::class)->getMock();
$query
->expects($this->once())
->method('execute')
->will($this->returnValue($result))
;
- $ldap = $this->getMock(LdapInterface::class);
+ $ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$result
->expects($this->once())
->method('offsetGet')