Skip to content

Instantly share code, notes, and snippets.

@davividal
Last active August 14, 2017 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davividal/06e94e6f8048b0a60414365f9f10e103 to your computer and use it in GitHub Desktop.
Save davividal/06e94e6f8048b0a60414365f9f10e103 to your computer and use it in GitHub Desktop.
<?php
//...
namespace Tests\ApiBundle\TestCase;
//...
use Liip\FunctionalTestBundle\Test\WebTestCase as WebTestCase;
//...
abstract class BaseApiControllerTestCase extends WebTestCase
{
//...
public function tearDown()
{
if ($this->em instanceof EntityManager) {
$this->em->close();
}
$this->em = null;
$refl = new \ReflectionObject($this);
foreach ($refl->getProperties() as $prop) {
if (!$prop->isStatic() && 0 !== strpos($prop->getDeclaringClass()->getName(), 'PHPUnit_')) {
$prop->setAccessible(true);
$prop->setValue($this, null);
}
}
unset($refl);
\gc_collect_cycles();
parent::tearDown();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment