8000 updated documentation for the profiler usage in a functional test by fabpot · Pull Request #1727 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

updated documentation for the profiler usage in a functional test #1727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 19, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions book/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,19 @@ HTTP layer. For a list of services available in your application, use the
Accessing the Profiler Data
~~~~~~~~~~~~~~~~~~~~~~~~~~~

On each request, the Symfony profiler collects and stores a lot of data about
the internal handling of that request. For example, the profiler could be
used to verify that a given page executes less than a certain number of database
On each request, you can enable the Symfony profiler to collect data about the
internal handling of that request. For example, the profiler could be used to
verify that a given page executes less than a certain number of database
queries when loading.

To get the Profiler for the last request, do the following::

// enable the profiler for the very next request
$client->enableProfiler();

$crawler = $client->request('GET', '/profiler');

// get the profile
$profile = $client->getProfile();

For specific details on using the profiler inside a test, see the
Expand Down
10 changes: 7 additions & 3 deletions cookbook/testing/profiling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ various things and enforce some metrics.

The Symfony2 :ref:`Profiler <internals-profiler>` gathers a lot of data for
each request. Use this data to check the number of database calls, the time
spent in the framework, ... But before writing assertions, always check that
the profiler is indeed available (it is enabled by default in the ``test``
environment)::
spent in the framework, ... But before writing assertions, enable the profiler
and check that the profiler is indeed available (it is enabled by default in
the ``test`` environment)::

class HelloControllerTest extends WebTestCase
{
public function testIndex()
{
$client = static::createClient();

// Enable the profiler for the next request (it does nothing if the profiler is not available)
$client->enableProfiler();

$crawler = $client->request('GET', '/hello/Fabien');

// ... write some assertions about the Response
Expand Down
0