3

I want to rollback all queries made inside the symfony/panther test.

With the normal WebTestCase i can achieve that by

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

How to achieve the same with Panther since there is no $client->disableReboot() method?

AnC
  • 641
  • 4
  • 16
  • Your tests should not use database connection at all. If database is down, tests will not work, also think about development environments. – revengeance Apr 29 '19 at 13:39
  • 3
    I think it's not that bad to use a real db for functional tests -> https://symfony.com/doc/current/testing/database.html#changing-database-settings-for-functional-tests – AnC Apr 29 '19 at 14:47

0 Answers0