求解?《LX2 PHP 扩展包实战教程 - 从入门到发布》- 12 编写单元测试
// 检查 $type 参数
public function testGetWeatherWithInvalidType()
{
$w = new Weather('mock-key');
// 断言会抛出此异常类
$this->expectException(InvalidArgumentException::class);
// 断言异常消息为 'Invalid type value(base/all): foo'
$this->expectExceptionMessage('Invalid type value(base/all): foo');
$w->getWeather('深圳', 'foo1');
$this->fail('Failed to assert getWeather throw exception with invalid argument.');
}
这个单元测试为什么会通过呢?注意foo1和foo
推荐文章: