CodeIgniter Forums

Full Version: Testing current URI
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

As stated in this StackOverflow question, to which you can answer and win a few points, I am trying to run a unit test of a library that checks the value of string_uri().

In order to test it right, I have to mock the current URI, something like

PHP Code:
$_SERVER['PHP_SELF'] = 'my/custom/test/uri'


Unfortunately, that doesn't work.

I ended up by writing a function in the test suite that changes it and another one that overrides string_uri(). I don't like that, because I'm writing code that will never be tested.

Is there another way to mock the URI?