File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -194,13 +194,13 @@ class EmailTest extends TestCase
194
194
}
195
195
```
196
196
197
- 在上述代码中,第一个测试方法使用了基类提供的断言方法 assertInstanceOf 判断 Email::fromString 方法返回的是否是 Email 实例;第二个测试方法中使用了 expectException 判断传入无效的邮件地址是否抛出指定异常;第三个测试方法则使用 assertEquals 判断 Email::fromString 打印结果是否与给定字符串相等。
197
+ 在上述代码中,第一个测试方法使用了基类提供的断言方法 assertInstanceOf 判断 Email::fromString 方法返回的是否是 Email 实例;第二个测试方法中使用了 expectException 判断传入无效的邮件地址是否抛出指定异常;第三个测试方法则使用 ` assertEquals ` 判断 ` Email::fromString ` 打印结果是否与给定字符串相等。
198
198
199
199
下面我们来运行单元测试:
200
200
201
201
202
202
203
- 所有测试用例都显示绿色(包含了 FirstTest 里面的那个用例,所以是 4 个),表明 Email 类方法中的代码是按照我们预期的结果执行,测试通过。
203
+ 所有测试用例都显示绿色(包含了 ` FirstTest ` 里面的那个用例,所以是 4 个),表明 Email 类方法中的代码是按照我们预期的结果执行,测试通过。
204
204
205
205
好了,关于基于 PHPUnit 编写测试用例我们先简单介绍到这里,更多使用方法请参考官方文档,从下一篇开始我们将介绍如何在 Laravel 框架中集成 PHPUnit 编写单元测试代码。
206
206
You can’t perform that action at this time.
0 commit comments