我正在测试我的 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');
更新:我真正想知道的是,当未设置配置文件中的“域”键时,我应该如何测试我的方法是否引发异常。