Skip to content

Conversation

@fvdb
Copy link
Contributor

@fvdb fvdb commented Oct 9, 2014

Before PHPUnit 4.3.0, you could use PHPUnit_Framework_Constraint_ExceptionMessage to match an exception message using either a sub string, or a regular expression. Support for this was removed in this commit: sebastianbergmann/phpunit@eee0584

This means that if you use regular expressions to match invalid configuration exception messages, you need to change those to now use substrings instead.

This PR allows you to simply set an extra parameter "useRegExp" to true, which causes SymfonyConfigTest to instantiate the correct constraint class when using PHPUnit >= 4.3.0. The flag does nothing below 4.3.0, as the existing constraint class will support regular expressions just fine.

Copy link

Choose a reason for hiding this comment

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

👍 elegant

@fvdb
Copy link
Contributor Author

fvdb commented Oct 9, 2014

Build seems to fail for PHPUnit 3.7. Will fix.

@matthiasnoback
Copy link
Collaborator

Thanks @fvdb , I will look into this soon and then merge it!

@matthiasnoback
Copy link
Collaborator

Thanks for looking into this issue @fvdb. I think that instead of checking the actual version of PHPUnit, it would be just fine to check if that RegExp class exists. That way, when a new version suddenly doesn't have the class anymore, we won't need to modify the if clause again. What do you think?

@fvdb
Copy link
Contributor Author

fvdb commented Oct 12, 2014

Sounds good. Made the change.

@fvdb
Copy link
Contributor Author

fvdb commented Oct 12, 2014

Did a rebase to clean up the commit history.

matthiasnoback added a commit that referenced this pull request Oct 12, 2014
Ensured exception message regex matching keeps working with PHPUnit >=4.3.0
@matthiasnoback matthiasnoback merged commit 8d3a62a into SymfonyTest:master Oct 12, 2014
@matthiasnoback
Copy link
Collaborator

Thanks! Merged and tagged v0.4.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants