Skip to content

Instantly share code, notes, and snippets.

@stof
Created February 18, 2019 19:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stof/fb45ca5940159b2741081e1cb2dae3b0 to your computer and use it in GitHub Desktop.
Save stof/fb45ca5940159b2741081e1cb2dae3b0 to your computer and use it in GitHub Desktop.
CacheClearer to allow running tests with Symfony in non-debug mode
<?php
require __DIR__.'/../app/autoload.php';
(new \Incenteev\Tests\Util\CacheClearer())->clearCache();
<?php
namespace Incenteev\Tests\Util;
use Symfony\Component\Filesystem\Filesystem;
class CacheClearer
{
public function clearCache()
{
// Set the INCENTEEV_KEEP_CACHE env var if you know it is already fresh, for instance on CI
if (getenv('INCENTEEV_KEEP_CACHE')) {
return;
}
$filesystem = new Filesystem();
$filesystem->remove($this->getCacheFolders());
}
private function getCacheFolders()
{
return array(
__DIR__.'/../../../var/cache/test',
__DIR__.'/../../../var/cache/behat',
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment