/** * Removes all used services so that a new instance of a service gets * created. This ensures that our test has no side effects. This behaviour * is for some services unwanted like i.e. the db connection since we dont * want to re-establish a db connection for every test. Such services can be * listed in the _protectedServices property */ protected function clearServices() { // set original config Environment::getContainer()->set('config', Environment::getConfig()); // remove services $serviceIds = Environment::getContainer()->getServiceIds(); foreach ($serviceIds as $serviceId) { if (!in_array($serviceId, $this->_protectedServices)) { Environment::getContainer()->set($serviceId, null); } } }