@expectedExceptionMessageRegExp
The expected message can also be specified as a regular expression using the @expectedExceptionMessageRegExp
annotation. This is helpful for situations where a substring is not adequate for matching a given message.
use PHPUnit\Framework\TestCase; class MyTest extends TestCase { /** * @expectedException MyException * @expectedExceptionMessageRegExp /Argument \d+ can not be an? \w+/ */ public function testExceptionHasRightMessage() { throw new MyException('Argument 2 can not be an integer'); } }
Please login to continue.