Laravel 7: assertSee() and html entities

折月煮酒 提交于 2021-02-11 14:34:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!