Created
February 18, 2019 19:08
-
-
Save stof/fb45ca5940159b2741081e1cb2dae3b0 to your computer and use it in GitHub Desktop.
CacheClearer to allow running tests with Symfony in non-debug mode
This file contains hidden or 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 | |
require __DIR__.'/../app/autoload.php'; | |
(new \Incenteev\Tests\Util\CacheClearer())->clearCache(); |
This file contains hidden or 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 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