minor #11191 [Tests] fix tests due to recent changes in PHP's behavior (xabbuh)
This PR was merged into the 2.4 branch. Discussion ---------- [Tests] fix tests due to recent changes in PHP's behavior | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | #11176 | License | MIT | Doc PR | The drawback of this solution is that the pretty printed string produced by ``json_encode()`` isn't validated anymore. Instead, the tests only ensures that the represented object structure is as expected. I guess that's fair enough since the goal of the test is not to test PHP's pretty printing feature. Commits -------bc8042d
don't disable constructor calls to mockups of classes that extend internal PHP classesf4a3c7a
special handling for the JsonDescriptor to work around changes in PHP's JSON pretty printer
This commit is contained in:
commit
f45f2dfd00
@ -95,8 +95,13 @@ abstract class AbstractDescriptorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$options['raw_output'] = true;
|
$options['raw_output'] = true;
|
||||||
$output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
|
$output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
|
||||||
$this->getDescriptor()->describe($output, $describedObject, $options);
|
$this->getDescriptor()->describe($output, $describedObject, $options);
|
||||||
|
|
||||||
|
if ('json' === $this->getFormat()) {
|
||||||
|
$this->assertEquals(json_decode($expectedDescription), json_decode($output->fetch()));
|
||||||
|
} else {
|
||||||
$this->assertEquals(trim($expectedDescription), trim(str_replace(PHP_EOL, "\n", $output->fetch())));
|
$this->assertEquals(trim($expectedDescription), trim(str_replace(PHP_EOL, "\n", $output->fetch())));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function getDescriptionTestData(array $objects)
|
private function getDescriptionTestData(array $objects)
|
||||||
{
|
{
|
||||||
|
@ -129,7 +129,7 @@ class AuthenticationProviderManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
} elseif (null !== $exception) {
|
} elseif (null !== $exception) {
|
||||||
$provider->expects($this->once())
|
$provider->expects($this->once())
|
||||||
->method('authenticate')
|
->method('authenticate')
|
||||||
->will($this->throwException($this->getMock($exception, null, array(), '', false)))
|
->will($this->throwException($this->getMock($exception, null, array(), '')))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$userProvider = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface');
|
$userProvider = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface');
|
||||||
$userProvider->expects($this->once())
|
$userProvider->expects($this->once())
|
||||||
->method('loadUserByUsername')
|
->method('loadUserByUsername')
|
||||||
->will($this->throwException($this->getMock('Symfony\\Component\\Security\\Core\\Exception\\UsernameNotFoundException', null, array(), '', false)))
|
->will($this->throwException($this->getMock('Symfony\\Component\\Security\\Core\\Exception\\UsernameNotFoundException', null, array(), '')))
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider = new DaoAuthenticationProvider($userProvider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface'), 'key', $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface'));
|
$provider = new DaoAuthenticationProvider($userProvider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface'), 'key', $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface'));
|
||||||
@ -55,7 +55,7 @@ class DaoAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$userProvider = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface');
|
$userProvider = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface');
|
||||||
$userProvider->expects($this->once())
|
$userProvider->expects($this->once())
|
||||||
->method('loadUserByUsername')
|
->method('loadUserByUsername')
|
||||||
->will($this->throwException($this->getMock('RuntimeException', null, array(), '', false)))
|
->will($this->throwException($this->getMock('RuntimeException', null, array(), '')))
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider = new DaoAuthenticationProvider($userProvider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface'), 'key', $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface'));
|
$provider = new DaoAuthenticationProvider($userProvider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface'), 'key', $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface'));
|
||||||
|
@ -79,7 +79,7 @@ class PreAuthenticatedAuthenticationProviderTest extends \PHPUnit_Framework_Test
|
|||||||
$userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
|
$userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
|
||||||
$userChecker->expects($this->once())
|
$userChecker->expects($this->once())
|
||||||
->method('checkPostAuth')
|
->method('checkPostAuth')
|
||||||
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\LockedException', null, array(), '', false)))
|
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\LockedException', null, array(), '')))
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider = $this->getProvider($user, $userChecker);
|
$provider = $this->getProvider($user, $userChecker);
|
||||||
|
@ -52,7 +52,7 @@ class RememberMeAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
|
$userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
|
||||||
$userChecker->expects($this->once())
|
$userChecker->expects($this->once())
|
||||||
->method('checkPostAuth')
|
->method('checkPostAuth')
|
||||||
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\AccountExpiredException', null, array(), '', false)))
|
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\AccountExpiredException', null, array(), '')))
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider = $this->getProvider($userChecker);
|
$provider = $this->getProvider($userChecker);
|
||||||
|
@ -41,7 +41,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$provider = $this->getProvider(false, false);
|
$provider = $this->getProvider(false, false);
|
||||||
$provider->expects($this->once())
|
$provider->expects($this->once())
|
||||||
->method('retrieveUser')
|
->method('retrieveUser')
|
||||||
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\UsernameNotFoundException', null, array(), '', false)))
|
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\UsernameNotFoundException', null, array(), '')))
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider->authenticate($this->getSupportedToken());
|
$provider->authenticate($this->getSupportedToken());
|
||||||
@ -55,7 +55,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$provider = $this->getProvider(false, true);
|
$provider = $this->getProvider(false, true);
|
||||||
$provider->expects($this->once())
|
$provider->expects($this->once())
|
||||||
->method('retrieveUser')
|
->method('retrieveUser')
|
||||||
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\UsernameNotFoundException', null, array(), '', false)))
|
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\UsernameNotFoundException', null, array(), '')))
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider->authenticate($this->getSupportedToken());
|
$provider->authenticate($this->getSupportedToken());
|
||||||
@ -83,7 +83,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
|
$userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
|
||||||
$userChecker->expects($this->once())
|
$userChecker->expects($this->once())
|
||||||
->method('checkPreAuth')
|
->method('checkPreAuth')
|
||||||
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\CredentialsExpiredException', null, array(), '', false)))
|
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\CredentialsExpiredException', null, array(), '')))
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider = $this->getProvider($userChecker);
|
$provider = $this->getProvider($userChecker);
|
||||||
@ -103,7 +103,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
|
$userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
|
||||||
$userChecker->expects($this->once())
|
$userChecker->expects($this->once())
|
||||||
->method('checkPostAuth')
|
->method('checkPostAuth')
|
||||||
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\AccountExpiredException', null, array(), '', false)))
|
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\AccountExpiredException', null, array(), '')))
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider = $this->getProvider($userChecker);
|
$provider = $this->getProvider($userChecker);
|
||||||
@ -128,7 +128,7 @@ class UserAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
|
|||||||
;
|
;
|
||||||
$provider->expects($this->once())
|
$provider->expects($this->once())
|
||||||
->method('checkAuthentication')
|
->method('checkAuthentication')
|
||||||
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\BadCredentialsException', null, array(), '', false)))
|
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\BadCredentialsException', null, array(), '')))
|
||||||
;
|
;
|
||||||
|
|
||||||
$provider->authenticate($this->getSupportedToken());
|
$provider->authenticate($this->getSupportedToken());
|
||||||
|
Reference in New Issue
Block a user