We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a1ab550 commit 5bc8e0fCopy full SHA for 5bc8e0f
laravel/readme/25. 2019-06-24- 从基于 PHPUnit 编写单元测试开始.md
@@ -106,6 +106,7 @@ PHPUnit运行失败
106
107
在编写测试用例之前,先编写一个应用类 Email,我们在项目根目录下创建一个 app 目录,并将 Email.php 保存在该目录下,然后编写 Email 类代码如下:
108
109
+```
110
<?php
111
declare(strict_types=1);
112
@@ -143,13 +144,18 @@ final class Email
143
144
}
145
146
147
148
+
149
然后,我们在 composer.json 中配置 autoload 选项通过 PSR-4 规则加载 app 目录下的类文件:
150
151
152
"autoload": {
153
"psr-4": {
154
"App\\": "app/"
155
156
},
157
158
159
以便能够通过命名空间加载到 app 目录下的类。配置完成后,运行 composer dump-auto 命令重新生成自动加载文件以便 Email 类可以被正常加载到。
160
161
接下来,我们在 tests/Unit 目录下创建一个新的测试用例 EmailTest.php,用来测试刚刚编写的 Email 类:
0 commit comments