Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPUnit + Kohana: Undefined index: HTTP_HOST

Tags:

phpunit

kohana

Trying to run PHPUnit on my Kohana 2.3.4 install:

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

Getting an error at 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 realize this is happening since I'm going via command line so HTTP_HOST won't be set. Is there any way around this without rewriting HTTP_HOST in that module? I know I could rewrite it to be exec(hostname), but am trying to avoid rewriting every instance of HTTP_HOST in my code.

Any workaround you can think of?

like image 875
jmccartie Avatar asked Apr 14 '26 05:04

jmccartie


1 Answers

Quick and dirty way to fix it would be to set the value in the bootstrap if you're in cli mode.

The "better" way would be to set it in the test's setUp method

like image 191
Matt Avatar answered Apr 21 '26 04:04

Matt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!