当我运行具有 2 个断言 ( assertSee)的功能测试时,PHPUnit 仅识别一个 ( title) 而不是description,即使我可以清楚地看到它dd()是从控制器传递到视图的值。
考试:
/** @test */
public function a_user_can_view_a_project(){
$this->withoutExceptionHandling();
$project = factory('App\Project')->create();
$this->get('/projects/'.$project->id)->assertSee('title')->assertSee('description');
}
错误:
Failed asserting that '<!doctype html>\n
<html>\n
<head>\n
<meta charset="UTF-8">\n
<meta name="viewport"\n
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">\n
<meta http-equiv="X-UA-Compatible" content="ie=edge">\n
<title>Document</title>\n
</head>\n
<body>\n
<h3>Fugit molestias explicabo odio quis.</h3>\n
<p>Quis aut consectetur quisquam a dolores voluptatibus. Quas quos quo iusto beatae sint voluptatem aspernatur. Molestiae repudiandae suscipit non vel. Ea quasi et eveniet.</p>\n
Quis aut consectetur quisquam a dolores voluptatibus. Quas quos quo iusto beatae sint voluptatem aspernatur. Molestiae repudiandae suscipit non vel. Ea quasi et eveniet.\n
</body>\n
</html>\n
' contains "description".
该段落是它无法“看到”的描述。
dd():
.
.
.
#attributes: array:5 [▼
"id" => 1
"title" => "First Project"
"description" => "asdsdasdsadsadsadsadsa"
"created_at" => null
"updated_at" => null
]
.
.
.
斯蒂芬大帝