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="blo开发者_如何学编程ck">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?
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
Is this $_SERVER['HTTP_HOST']
?
If so, have a look at adding an xml config file and setting it in there:
https://phpunit.de/manual/current/en/appendixes.configuration.html
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.
精彩评论