-
-
Save edorian/4143622 to your computer and use it in GitHub Desktop.
PHPUnit Cache Clear beforeClass
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 | |
namespace Lingwa\Bundle\CoreBundle\Test; | |
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; | |
abstract class BaseTestCase extends WebTestCase | |
{ | |
static $cleared = false; | |
public static function setupBeforeClass() | |
{ | |
$class = get_called_class(); | |
if (strpos($class, '\\Controller\\') && !self::$cleared) { | |
require_once SF_ROOT.'/app/AppKernel.php'; | |
$interpreter = PHP_OS == 'WINNT' ? 'php.exe' : 'php'; | |
@passthru(sprintf('%s app/console cache:clear --env=test --no-debug', $interpreter)); | |
self::$cleared = true; | |
} | |
} | |
protected function tearDown() | |
{ | |
$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); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment