Why is testing singletons or registry pattern hard in a language like PHP which is request driven?
You can write and run tests aside from the actual program executio
When finishing a PHP test, you can flush singleton instance like this:
protected function tearDown() { $reflection = new ReflectionClass('MySingleton'); $property = $reflection->getProperty("_instance"); $property->setAccessible(true); $property->setValue(null); }