I'm currently writing unit tests for an API written in PHP. This API implements a RateLimiting step before each request, and I want to avoid this step while I'm testing the application.
Now, if I want to run the tests locally I just have to check the local IP, which is "::1". But I'm having problems accessing the environment variables that my continuous integration server provides (I am using wercker).
If I run this from a PHPUnit test:
var_export(isset($_SERVER["CI"]) || isset($_SERVER["wercker"]));
I get true
, but if I do do something similar before applying the rate limiting:
if (isset($_SERVER["CI"]) || $request->getIp() === "::1") {
return;
} else {//...
the wercker tests keep failing because it never skips the rate limiting logic. Notice that the first piece of code is run from a test in PHPUnit, while the second one is part of the server application.
What am I doing wrong with the environment variables?
Please let me know if I must provide more information or documentation.