Skip to content

Commit 7c71b18

Browse files
committed
feature #2952 Enabling profiler in test (danieledangeli)
This PR was merged into the master branch. Discussion ---------- Enabling profiler in test | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | 2.3 | Fixed tickets | no Some people have open issues about how enabling the profiler in test enviroment. The option ``enable profiler`` working correctly but some people don't want enabling the data collecting in each tests. So you can define in "config_test.yml" the collect parameter to false. The data will collect only in tests that call $client->enableProfiler(); Commits ------- d03f39d Added configuration to enable profiler in test
2 parents e9a1a32 + d03f39d commit 7c71b18

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

book/testing.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,52 @@ To get the Profiler for the last request, do the following::
487487
For specific details on using the profiler inside a test, see the
488488
:doc:`/cookbook/testing/profiling` cookbook entry.
489489

490+
To avoid collecting data in each test you can set the ``collect`` parameter
491+
in the configuration:
492+
493+
.. configuration-block::
494+
495+
.. code-block:: yaml
496+
497+
# app/config/config_test.yml
498+
499+
# ...
500+
framework:
501+
profiler:
502+
enabled: true
503+
collect: false
504+
505+
.. code-block:: xml
506+
507+
<!-- app/config/config.xml -->
508+
<?xml version="1.0" encoding="UTF-8" ?>
509+
<container xmlns="http://symfony.com/schema/dic/services"
510+
xmlns:framework="http://symfony.com/schema/dic/symfony"
511+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
512+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
513+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
514+
515+
<!-- ... -->
516+
517+
<framework:config>
518+
<framework:profiler enabled="true" collect="false" />
519+
</framework:config>
520+
</container>
521+
522+
.. code-block:: php
523+
524+
// app/config/config.php
525+
526+
// ...
527+
$container->loadFromExtension('framework', array(
528+
'profiler' => array(
529+
'enabled' => true,
530+
'collect' => false,
531+
),
532+
));
533+
534+
In this way only tests that call ``enableProfiler()`` will collect data.
535+
490536
Redirecting
491537
~~~~~~~~~~~
492538

0 commit comments

Comments
 (0)