首页 > 解决方案 > Symfony Panther - 功能测试中的回滚数据库事务

问题描述

我想回滚在 symfony/panther 测试中进行的所有查询。

使用普通的 WebTestCase 我可以通过

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();
    }
}

由于没有方法,如何与Panther$client->disableReboot()实现相同的效果?

标签: symfonyphpunitsymfony-panther

解决方案


推荐阅读