当我运行 PHPUnit 6.5.13 时。并在此示例之后有一个测试方法PHPUnit Testing Exceptions Documentation
public function testSetRowNumberException()
{
$this->expectException(\InvalidArgumentException::class);
$result = $this->tableCell->setRowNumber('text');
}
测试此方法:
public function setRowNumber(int $number) : TableCell
{
if (!is_int($number)) {
throw new \InvalidArgumentException('Input must be an int.');
}
$this->rowNumber = $number;
return $this;
}
我遇到了这个失败:
断言“TypeError”类型的异常与预期的异常“InvalidArgumentException”匹配失败。
问题是为什么"TypeError"
要使用断言以及如何使用断言InvalidArgumentException
?