运行测试后如何删除Symfony内核的/cache dir?

运行测试后如何删除Symfony内核的/cache dir?,symfony,testing,phpunit,Symfony,Testing,Phpunit,当使用Symfony内核运行测试时,它会创建/cache和/logs目录 此时,我用phpunit.xml加载自己的文件: <?php require_once __DIR__.'/../vendor/autoload.php'; // clear cache register_shutdown_function(function () { Nette\Utils\FileSystem::delete(__DIR__.'/cache'); Nette\Utils\Fil

当使用Symfony
内核运行测试时,它会创建
/cache
/logs
目录

此时,我用
phpunit.xml
加载自己的文件:

<?php

require_once __DIR__.'/../vendor/autoload.php';

// clear cache
register_shutdown_function(function () {
    Nette\Utils\FileSystem::delete(__DIR__.'/cache');
    Nette\Utils\FileSystem::delete(__DIR__.'/logs');
});
您可以实现

tests/ClearLogAndCacheTestListener.php

然后在
phpunit.xml
config中启用,并从测试文件夹中删除自定义
autoload.php

phpunit.xml


[...]

希望此帮助

hi@tomáš-votruba检查我的更新,如果对您的要求有投诉,谢谢您的回答。这是目前为止最好的,所以我会在实践中尝试它如何适合。我在寻找类似“禁用Symfony内核缓存”或“Symfony内核关闭清理”之类的东西。试图避开另一层来解决问题。我正在等待其他响应。顺便说一句,它可以缩短为:
。此外,每个测试都会运行此侦听器<代码>$testSuite->getName()
是必需的,如下所示:
namespace Symplify\DefaultAutowire\Tests;



class ClearLogAndCacheTestListener extends \PHPUnit_Framework_BaseTestListener
{
    public function endTestSuite(\PHPUnit_Framework_TestSuite $suite)
    {
        \Nette\Utils\FileSystem::delete(__DIR__.'/cache');
        \Nette\Utils\FileSystem::delete(__DIR__.'/logs');
    }

}
<phpunit
    bootstrap="vendor/autoload.php"
    colors="true"
    syntaxCheck="true"
    verbose="true"
>
    <listeners>
        <listener class="Symplify\DefaultAutowire\Tests\ClearLogAndCacheTestListener">
        </listener>
    </listeners>
[...]
</phpunit>