0
我是PHPUnit的新手,只是通过手册进行深入的探究,但我找不到一个体面的例子,说明如何从头到尾构建一个完整的测试,所以我留下了一些问题。如何使用PHPUnit中的构造?
其中之一是如何准备我的环境以正确测试我的代码?
我想弄清楚如何正确传递测试设置/拆卸方法以及类本身的配置所需的各种配置值。
// How can I set these variables on testing start?
protected $_db = null;
protected $_config = null;
// So that this function runs properly?
public function setUp(){
$this->_acl = new acl(
$this->_db, // The database connection for the class passed
// from whatever test construct
$this->_config // Config values passed in from construct
);
}
// Can I just drop in a construct like this, and have it work properly?
// And if so, how can I set the construct call properly?
public function __construct(
Zend_Db_Adapter_Abstract $db, $config = array(),
$baselinedatabase = NULL, $databaseteardown = NULL
){
$this->_db = $db;
$this->_config = $config;
$this->_baselinedatabase = $baselinedatabase;
$this->_databaseteardown = $databaseteardown;
}
// Or is the wrong idea to be pursuing?
您使用的是完整的Zend框架瓦特/的application.ini配置文件? – allnightgrocery 2010-06-01 13:08:41
@Inkspeak我的服务器上有ZF,所以我可以包含任何我想要的组件。我已经单独安装了PHPUnit,因此我正在寻找一组需要尽可能少的ZF代码的测试。 – 2010-06-01 14:36:03