Laravel PHPUnit没有获得正确的URL [英] Laravel phpunit not getting right url

查看:56
本文介绍了Laravel PHPUnit没有获得正确的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将app.url配置值更改为正确的URL(http://testing.local)以进行本地测试,但是,当我运行phpunit测试并尝试调用()时,它正在尝试查询http://localhost而不是app.url的值.我需要做些什么才能使phpunit调用正确的路径?

I've changed the app.url config value to the correct url (http://testing.local) for testing locally, however when I run my phpunit tests and try to call(), it is trying to query http://localhost instead of the value of app.url. What do I need to do to get phpunit to call the right path?

我知道它实际上不是在调用url,只是像对待它一样进行处理,但是我似乎无法使它真正起作用.可能与test.local直接链接到/public而不是/有关吗?

I know that it is not actually calling the url, just processing it as if it was, but I can't seem to get it to actually work. Could it have something to do with testing.local directly linking to /public instead of /?

推荐答案

更改PHPUnit的测试URL:

To change testing url of PHPUnit:

在您的Laravel项目中转到/tests/TestCase.php.

Go to /tests/TestCase.php in your Laravel project.

将下一行更改为所需的网址:

Change next line to url you need:

// The base URL to use while testing the application.
protected $baseUrl = 'http://newurl.com';

完成.

这篇关于Laravel PHPUnit没有获得正确的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆