业务没执行,就断言,是几个意思?
laraverer
3年前
修改理由:
相关信息:
- 类型:教程文章
- 文章: 编写单元测试
- 课程: 《LX2 PHP 扩展包实战教程 - 从入门到发布()》
此投稿状态为 标记为已读。
内容修改:
Old | New | Differences |
---|---|---|
172 | 172 | // 检查 $type 参数 |
173 | 173 | public function testGetWeatherWithInvalidType() |
174 | 174 | { |
175 | $w = new Weather('mock-key'); | |
175 | ||
176 | ||
177 | $w->getWeather('深圳', 'foo'); | |
178 | $w = new Weather('mock-key'); | |
176 | 179 | |
177 | 180 | // 断言会抛出此异常类 |
178 | 181 | $this->expectException(InvalidArgumentException::class); |
179 | 182 | |
180 | 183 | // 断言异常消息为 'Invalid type value(base/all): foo' |
181 | 184 | $this->expectExceptionMessage('Invalid type value(base/all): foo'); |
182 | ||
183 | ||
184 | 185 | |
185 | 186 | $this->fail('Failed to assert getWeather throw exception with invalid argument.'); |
186 | 187 | } |