lundi 5 février 2018

Codeception is not cleaning up Doctrine2 database after tests

Here is my unit.suite.yml

actor: UnitTester
modules:
   enabled:
      - Asserts
      - Doctrine2:
          depends: Symfony
          cleanup: true
      - \Helper\Unit

And here is my test:

public function testGetMostRecentSearchByZip()
{
    $search1 = $this->tester->haveInRepository(TestObject::class, [
        "zip"           => 12345,
        "queryParameters"   => [],
        "payload"           => "",
        "payloadChecksum"   => ""
    ]);

    $search2 = $this->tester->haveInRepository(TestObject::class, [
        "zip"           => 12345,
        "queryParameters"   => [],
        "payload"           => "",
        "payloadChecksum"   => ""
    ]);

    $em = $this->getModule("Doctrine2")->em;

    $expected = $em->find(TestObject::class, $search2);
    $result = $em->getRepository("AppBundle:TestObject")
        ->findByZip(12345);

    \Codeception\Util\Debug::debug($result);

    $this->assertEquals($expected->getId(), $result->getId());
}

After I run the test, I see in my database that the two test objects I created are still there, despite the Codeception documentation saying that the rows will be created within a transaction and rolled back after the tests. This is the documentation I'm referring to. Am I missing something here?

Aucun commentaire:

Enregistrer un commentaire