tags:

views:

46

answers:

3

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?

+2  A: 

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

Matt
A: 

We actually decided to use a different bootstrap, load in variables there, then require the Kohana index file.

Works like a charm. Thanks, Matt, for getting me started down that path.

jmccartie
+1  A: 

is this $_SERVER['HTTP_HOST']?

If so have a look at adding xml config file and setting it in there

http://www.phpunit.de/manual/current/en/appendixes.configuration.html

Shaun Hare