我正在测试我的Zend Framework应用程序,并希望测试在注册表中未设置特定键时发生的事情.这是我正在测试的功能:
protected function getDomainFromConfig() {
$config = Zend_Registry::get('config');
if (!isset($config->domain)) {
throw new Exception('Please make sure you have "domain" set in your config file and your config file is being set in the Zend_Registry.');
}
return $config->domain;
}
如何取消注册表中的密钥?我试过这个,但它不起作用:
$config = Zend_Registry::get('config');
$config->__unset('domain');
更新:我真正想知道的是,如果未设置配置文件中的“domain”键,我应该如何测试我的方法抛出异常.