Skip to content

[Security] Replace exception mocks with actual exception instances. #10621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2014

Conversation

jakzal
Copy link
Contributor

@jakzal jakzal commented Apr 2, 2014

It is done for two reasons:

  • consistency - we use real exception objects in most of the code
  • latest phpunit does not like the way we were creating mocks for exceptions (it could be also fixed by letting phpunit to call the original constructor)

It is done for two reasons:
* consistency - we use real exception objects in most of the code
* latest phpunit does not like the way we were creating mocks for exceptions (it could be also fixed by letting phpunit to call the original constructor)
@jakzal jakzal added the Security label Apr 2, 2014
@@ -129,7 +129,7 @@ protected function getAuthenticationProvider($supports, $token = null, $exceptio
} elseif (null !== $exception) {
$provider->expects($this->once())
->method('authenticate')
->will($this->throwException($this->getMock($exception, null, array(), '', false)))
->will($this->throwException($this->getMock($exception, null, array(), '', true)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we pass a real exception instead of a classname?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in this specific case, since one of the exception classes here is abstract (Symfony\Component\Security\Core\Exception\AccountStatusException).

fabpot added a commit that referenced this pull request Apr 3, 2014
… instances. (jakzal)

This PR was merged into the 2.3 branch.

Discussion
----------

[Security] Replace exception mocks with actual exception instances.

It is done for two reasons:
* consistency - we use real exception objects in most of the code
* latest phpunit does not like the way we were creating mocks for exceptions (it could be also fixed by letting phpunit to call the original constructor)

Commits
-------

9438f88 [Security] Replace exception mocks with actual exception instances.
@fabpot fabpot merged commit 9438f88 into symfony:2.3 Apr 3, 2014
@jakzal jakzal deleted the security-tests-fix branch April 3, 2014 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants