PHPUnit + Kohana:未定义的索引:HTTP_HOST

jmc*_*tie 3 phpunit kohana

试图在我的Kohana 2.3.4安装上运行PHPUnit:

phpunit --colors --bootstrap=index.php ../../modules/phpunit/libraries/Tests.php
Run Code Online (Sandbox Code Playgroud)

在我的一个模块上出错:

<p><tt>modules/core/helpers/MY_url.php <strong>[118]:</strong></tt></p>
<p><code class="block">Undefined index: HTTP_HOST</code></p>
Run Code Online (Sandbox Code Playgroud)

我意识到这种情况正在发生,因为我要通过命令行,所以不会设置HTTP_HOST.如果没有在该模块中重写HTTP_HOST,有没有办法解决这个问题?我知道我可以将它重写为exec(hostname),但我试图避免在我的代码中重写HTTP_HOST的每个实例.

你能想到的任何解决方法?

Mat*_*att 5

如果你处于cli模式,修复它的快速和脏的方法是设置引导程序中的值.

"更好"的方法是在测试的setUp方法中设置它