CodeIgniter Forums
Testing current URI - Printable Version

+- CodeIgniter Forums (
+-- Forum: CodeIgniter 4 (
+--- Forum: CodeIgniter 4 Support (
+--- Thread: Testing current URI (/thread-77482.html)

Testing current URI - SteeveDroz - 09-06-2020


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?