我有以下代码:
public function method(){
//...
if(!$exist) {
throw new \InvalidArgumentException('Ce client inexistant', 400);
}
}
我做这段代码的UT:
public function methodTest(){
//...
if(!$exist) {
$this->expectExceptionMessage("Ce client inexistant");
$this->expectException("\InvalidArgumentException");
}
}
它显示一条错误消息
断言引发类型为“ \ InvalidArgumentException”的异常失败。
我不知道我的代码中的错误在哪里。
我解决了我的问题。这是代码:
$ this-> throwException(new \ InvalidArgumentException('Ce client inexistant',400));
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句