Skip to content

Commit d03f39d

Browse files
Added configuration to enable profiler in test
1 parent 69be273 commit d03f39d

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
@@ -473,6 +473,52 @@ To get the Profiler for the last request, do the following::
473473
For specific details on using the profiler inside a test, see the
474474
:doc:`/cookbook/testing/profiling` cookbook entry.
475475

476+
To avoid collecting data in each test you can set the ``collect`` parameter
477+
in the configuration:
478+
479+
.. configuration-block::
480+
481+
.. code-block:: yaml
482+
483+
# app/config/config_test.yml
484+
485+
# ...
486+
framework:
487+
profiler:
488+
enabled: true
489+
collect: false
490+
491+
.. code-block:: xml
492+
493+
<!-- app/config/config.xml -->
494+
<?xml version="1.0" encoding="UTF-8" ?>
495+
<container xmlns="http://symfony.com/schema/dic/services"
496+
xmlns:framework="http://symfony.com/schema/dic/symfony"
497+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
498+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
499+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
500+
501+
<!-- ... -->
502+
503+
<framework:config>
504+
<framework:profiler enabled="true" collect="false" />
505+
</framework:config>
506+
</container>
507+
508+
.. code-block:: php
509+
510+
// app/config/config.php
511+
512+
// ...
513+
$container->loadFromExtension('framework', array(
514+
'profiler' => array(
515+
'enabled' => true,
516+
'collect' => false,
517+
),
518+
));
519+
520+
In this way only tests that call ``enableProfiler()`` will collect data.
521+
476522
Redirecting
477523
~~~~~~~~~~~
478524

0 commit comments

Comments
 (0)