... not knowing if \'mock\' is the right word.
Anyway, I have an inherited code-base that I\'m trying to write some tests for that are time-based. Trying not to be <
Here's an addition to fab's post. I did the namespace based override using an eval. This way, I can just run it for tests and not the rest of my code. I run a function similar to:
function timeOverrides($namespaces = array()) {
$returnTime = time();
foreach ($namespaces as $namespace) {
eval("namespace $namespace; function time() { return $returnTime; }");
}
}
then pass in timeOverrides(array(...))
in the test setup so that my tests only have to keep track of what namespaces time() is called in.