[英]How do I unit test the view path?
I have a redirection procedure. 我有一个重定向过程。 If an auth check fails, redirect the user to a specific page. 如果身份验证检查失败,则将用户重定向到特定页面。 If the auth check passes, load a view. 如果认证检查通过,请加载视图。
In my unit testing script, I am using Laravel's own assertRedirectedTo on the fail procedure, which works fine: 在我的单元测试脚本中,我在失败过程中使用了Laravel自己的assertRedirectedTo,可以正常工作:
$this->assertRedirectedTo('users/create');
However, I want to check that if it passes, the view that is rendered is users/index
- this is not a redirection, so I just want to check the path of the view to ensure it's correct. 但是,我想检查是否通过,呈现的视图是users/index
-这不是重定向,所以我只想检查视图的路径以确保它是正确的。
I can't seem to find any way to return the view path in this form to assert against. 我似乎找不到任何方法以这种形式返回要声明的视图路径。
At present, I'm testing against the title, but I feel this will be redundant, because the title may change in future, and in that respect, the test should still pass. 目前,我正在针对标题进行测试,但是我觉得这将是多余的,因为标题可能会在将来更改,并且在这方面,测试仍应通过。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.