我正在做一个TDD项目,我只是想确保密码不会被错误地返回.这是我写的试卷.
public function testInfoMethodJsonStructure(){
$user = User::factory()->create();
$response =
$this
->actingAs($user)
->get('/api/profile/info');
$response->assertStatus(200);
$response->assertJsonStructure(['name', 'fullname', 'email']);
$response->assertJsonMissing(['password']); // this passes.
$response->assertJsonMissing(['password' => $user->password]); // this does not pass.
}
我知道密码正在返回,但为什么当我只传递密钥时,assertJsonMissing就不起作用了?如果不使用它,那么判断数据密钥是否丢失的正确方法是什么?