I am new into PHPUnit, and just digging through the manual. I cannot find a decent example of how to build a complete test from end to end though, and so, am left with questions.
One of these is how can I prep my environment to properly test my code?
I am trying to figure out how to properly pass various configuration values needed for both the test setup/teardown methods, and the configs for the class itself.
// 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?