PHPUnit\Framework\TestCase和Tests\TestCase的区别
What is the difference between PHPUnit\Framework\TestCase and Tests\TestCase?
翻译成中文就是 PHPUnit\Framework\TestCase
只有PHPUnit提供的功能,换句话说就是没有 Laravel 提供的功能。
而 Tests\TestCase
有各种 Laravel app 的功能,包括
- Eloquent factories
- Facades (and fakes)
- Unit testing components that use global helpers (e.g. config())
- 数据库事务&重置
- Laravel提供的断言等
PS:
PHPUnit\Framework\TestCase
是Tests\TestCase
的基类,所以 PHPUnit 的方法也可以用(如果没有被重写)
推荐文章: