我想为我的测试启用 symfony 分析器,我遵循了这个 documentation但我的探查器保持空白。我正在使用 PHPUnit 7.5.16 和 Symfony 4.3.4 以及 PHP 7.2.19。 我应该添加什么?
#web_profiler:
# toolbar: false
# intercept_redirects: false
#
#framework:
# profiler: { collect: false }
web_profiler:
toolbar: true
intercept_redirects: false
framework:
# profiler: { only_exceptions: false }
# make tests slowest, but it s usefull in local,watch this doc: https://symfony.com/doc/current/testing/profiling.html
profiler: { enabled: true, collect: true }
在我的 setUp() 方法中
parent::setUp();
$client = static::createClient();
$client->enableProfiler();
最佳答案
您可能还需要:
framework:
test: true
由于您在测试中启用了配置文件,因此您不需要这样做
framework:
profiler: { enabled: true, ... # can be 'enabled: false', if you enable it in a test
我自己的测试环境配置是:
> bin/console -e test debug:config framework profiler
Current configuration for "framework.profiler"
==============================================
enabled: true
collect: false
only_exceptions: false
only_master_requests: false
dsn: 'file:%kernel.cache_dir%/profiler'
和框架:测试:真
。有了这个配置,我就有了一个启用配置文件的测试环境,并检查其中的结果。
关于Symfony/PHPUnit 在测试中启用分析器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58415436/