【发布时间】:2011-08-18 18:53:26
【问题描述】:
我想测试一个使用 PHPUnit 的 PHPUnit_Extensions_Database_TestCase 类跨多个模式进行查询的过程。我已经翻阅了文档、SO 和源代码,但似乎我必须使用以下内容设置我的数据库:
protected function getConnection()
{
$this->pdo = new PDO('mysql:host=localhost;dbname=unit_test_schema', 'xxxx', 'yyyy');
return $this->createDefaultDBConnection($this->pdo, 'unit_test_schema');
}
protected function getDataSet()
{
return $this->createXMLDataSet(DB_SETUP_DIR.'/schema.xml');
}
有没有办法以某种方式使用多个架构,以便我可以测试如下查询:
SELECT *
FROM schema1.tableA
JOIN schema2.tableB
USING (id)
编辑: 明确地说,我要解决的问题是我只能弄清楚如何将架构设置文件传递到一个数据库。我想找到一种方法来表示“在 schema1 中创建 tables1.xml,在 schema2 中创建 tables2.xml”。在不同的 xml 文件中引用的表将在每次测试中被填充和终止。
【问题讨论】:
标签: php mysql unit-testing phpunit