我想创建一个空的测试表。使用来自digitalsandwich的Example,我想要类似的东西:
require_once 'PHPUnit/Extensions/Database/TestCase.php';
class BankAccountDBTest extends PHPUnit_Extensions_Database_TestCase
{
protected $pdo;
public function __construct()
{
$this->pdo = new PDO('sqlite::memory:');
BankAccount::createTable($this->pdo);
}
protected function getConnection()
{
return $this->createDefaultDBConnection($this->pdo, 'sqlite');
}
protected function getDataSet()
{
return $this->createFlatXMLDataSet(dirname(__FILE__).'/_files/empty-seed.xml');
}
public function testEmptyTableBehavior()
{
// test stuff
}
}
我应该使用与createFlatXMLDataSet()不同的方法吗?或???
答案 0 :(得分:22)
好的,我明白了:
...
require_once 'PHPUnit/Extensions/Database/DataSet/DefaultDataSet.php';
class BankAccountDBTest extends PHPUnit_Extensions_Database_TestCase
{
...
protected function getDataSet()
{
return new PHPUnit_Extensions_Database_DataSet_DefaultDataSet();
}