多个数据集是否有可能在加载多的PHPUnit平整的xml数据集加载大量的家具?PHPUnit的:数据库测试
我们正在写一个相当复杂的应用程序和XML数据集变得相当大,所以我想它陷入2-3的XML。
下面是一个测试用例当前代码:
<?php
class My_TestBase extends Zend_Test_PHPUnit_DatabaseTestCase{
/**
* Zend_Application
* @var Zend_Application
*/
protected $_application;
/**
* Connection
*
* @var Zend_Test_PHPUnit_Db_Connection
*/
private $_connection;
/**
* Returns the test database connection.
*
* @link http://framework.zend.com/wiki/display/ZFPROP/Zend_Test_PHPUnit_Database+-+Benjamin+Eberlei
* @return PHPUnit_Extensions_Database_DB_IDatabaseConnection
*/
protected function getConnection(){
if($this->_connection === null){
$Resources = $this->_application->getOption("resources");
$conn = Zend_Db::factory($Resources["db"]["adapter"], $Resources["db"]["params"]);
$this->_connection = $this->createZendDbConnection($conn, $Resources["db"]["params"]["dbname"]);
}
return $this->_connection;
}
/**
* Returns the test dataset.
*
* @link http://framework.zend.com/wiki/display/ZFPROP/Zend_Test_PHPUnit_Database+-+Benjamin+Eberlei
* @return PHPUnit_Extensions_Database_DataSet_IDataSet
*/
protected function getDataSet(){
return $this->createFlatXMLDataSet(__DIR__."/seed_data.xml");
}
/**
* Setup
*/
protected function setUp(){
$this->_application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
}
}
哇,恰好碰到了同样的问题,但不是处理复杂的数据集,我宁愿让他们的原子,使他们能够在其他测试中使用。将数据集紧密结合到特定测试没有多大意义。你能弄明白吗? –
不幸的是,不!我们有很多,每次考试所需的夹具(我们有好几个表连接在一起),复制灯具在每个测试情况下,许多文件可以到十个分量对我们来说是痛苦。去与劈裂XML灯具的唯一方法就是建立一些包装类Zend_Test_PHPUnit_DatabaseTestCase和编写一个“addXmlFile”的方法,但我没有时间这样做。下一次,我会明确地使用单独的yaml装置在需要时加载。 –