问题
In my test, I use assertSee().
$message = '<h1>Header</h1>';
$response = $this->get($url);
$response->assertStatus(200);
$response->assertSee($message);
The problem is that when the $message
contains html entities then the assertion gets false.
I know there is an e()
helper to do convert html entities in $message but now I need the opposite.
How can I do it?
回答1:
->assertSee(...) is changed in Laravel 7, now it has a second parameter
$response->assertSee($value, $escaped = true);
Just set it to false
.
Documentation says:
This assertion will automatically escape the given string unless you pass a second argument of false:
来源:https://stackoverflow.com/questions/64037805/laravel-7-assertsee-and-html-entities