Symfony Panther-功能测试中的回滚db事务
我想回滚symfony/panther测试中的所有查询 使用普通的WebTestCase,我可以通过Symfony Panther-功能测试中的回滚db事务,symfony,phpunit,symfony-panther,Symfony,Phpunit,Symfony Panther,我想回滚symfony/panther测试中的所有查询 使用普通的WebTestCase,我可以通过 protected function setUp() { parent::setUp(); $this->client = static::createClient(); $this->client->disableReboot(); $this->connection = $this->client->getContainer
protected function setUp()
{
parent::setUp();
$this->client = static::createClient();
$this->client->disableReboot();
$this->connection = $this->client->getContainer()->get('doctrine')->getConnection();
$this->connection->beginTransaction();
$this->connection->setAutoCommit(false);
}
protected function tearDown()
{
parent::tearDown();
if ($this->connection->isTransactionActive()) {
$this->connection->rollback();
}
}
由于没有
$client->disableReboot()
方法,如何实现相同的功能?您的测试根本不应该使用数据库连接。如果数据库关闭,测试将无法工作,还要考虑开发环境。我认为使用真正的数据库进行功能测试并没有那么糟糕->