PHPUnit + Kohana: Undefined index: HTTP_HOST

Trying to run PHPUnit on my Kohana 2.3.4 install:

phpunit --colors --bootstrap=index.php ../../modules/phpunit/libraries/Tests.php

Getting an error in one of my modules:

<p><tt>modules/core/helpers/MY_url.php <strong>[118]:</strong></tt></p>
<p><code class="block">Undefined index: HTTP_HOST</code></p>

I understand that this is happening as I go through the command line, so HTTP_HOST will not be set. Is there any way around this without overwriting HTTP_HOST in this module? I know that I can rewrite it as exec (hostname), but try to avoid rewriting every instance of HTTP_HOST in my code.

Any workaround you can think of?

+3
source share
3 answers

Is it $_SERVER['HTTP_HOST']?

If so, see how to add the xml configuration file and install it there:

https://phpunit.de/manual/current/en/appendixes.configuration.html

+4

, cli.

"" setUp test

+5

In fact, we decided to use a different boot file, loading the variables into it, then we require the Kohana index file.

It works like a charm. Thanks Matt for starting this way.

0
source

Source: https://habr.com/ru/post/1768266/


All Articles