Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • For sure the most sugar in this syntax Commented Dec 4, 2019 at 4:03
  • 2
    It seems that expectExceptionMessage behaves as a Regex. If your error message is 'Foo bar Baz', $this->expectExceptionMessage('Foo'); will make the test pass. Commented Jun 25, 2020 at 17:08
  • 2
    this is the one! also, expectExceptionCode(401)
    – darryn.ten
    Commented Oct 15, 2020 at 3:02
  • @LucasBustamante expectExceptionMessage($message) will work as long as the actual exception message contains the specified message. Internally PHPUnit uses strpos to evaluate the condition.
    – Sébastien
    Commented May 9, 2022 at 15:53