Created
March 24, 2020 22:33
-
-
Save mirdic/93d056d619864fe48343fea92ba8b19d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php declare(strict_types=1); | |
namespace Test\Functional\ApiModule\V1Module; | |
class BaseApiTest extends BaseFunctionalTest | |
{ | |
protected function _before() | |
{ | |
/** @var EntityManager $em */ | |
$em = $this->tester->grabService(EntityManager::class); | |
$em->clear(); | |
if ($em->getConnection()->isTransactionActive()) { | |
try { | |
while ($em->getConnection()->getTransactionNestingLevel() > 0) { | |
$em->getConnection()->rollback(); | |
} | |
} catch (\PDOException $e) { | |
} | |
} | |
$em->getConnection()->beginTransaction(); | |
} | |
protected function _after() | |
{ | |
/** @var EntityManager $em */ | |
$em = $this->tester->grabService(EntityManager::class); | |
try { | |
while ($em->getConnection()->getTransactionNestingLevel() > 0) { | |
$em->getConnection()->rollback(); | |
} | |
} catch (\PDOException $e) { | |
} | |
$em->clear(); | |
$em->getConnection()->close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment