Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport fix for #2731 from PHPUnit 6.4 to PHPUnit 5.7
- Loading branch information
1 parent
905862c
commit 567ca23
Showing
2 changed files
with
20 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
567ca23
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so, what about
setExpectedException
now ?if I set
->setExpectedException(MyException::class, '')
it wont trigger checking if exception msg is empty.Sadly, default value for
$message
param is''
, but expected behaviour is when one pass only exception name, we shall not test message. To not break interface, it shall be checked via number of arguments to not break BC by changing default value of param567ca23
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setExpectedException()
no longer exists in PHPUnit 6, that is why I forgot about it when backporting the fix to PHPUnit 5.7.Part of the motivation for
expectException()
etc. was the ugly API ofsetExpectedException()
that used optional parameters.What do you suggest should be done now for PHPUnit 5.7, @keradus? And can you send a pull request? :-)
567ca23
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I totally agree about dropping
setExpectedException
👍yet, PHPUnit 5 has it, and after this change it's problematic.
That's why I like to introduce any change via PR, even if it means I sent PR to my own project ;) More ppl have chance to look at change before, not after it's merged.
As I wrote:
So, keep prototype of this method as is (
setExpectedException($exception, $message = '', $code = null)
), but if one called method only with one argument, assume that$message=null
instead of empty string. This one, if one call it with 2 arguments and$message=''
, we shall respect it.If you agree with my proposal, I could sent a PR, sure!
567ca23
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me. Looking forward to your pull request!
567ca23
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#2807