Skip to content

Commit b2c0d38

Browse files
committed
Refactore how to get the container in a test
1 parent 47bda31 commit b2c0d38

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

testing.rst

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ expression or a CSS selector, then use the client to click on it. For example::
198198
->eq(1) // select the second link in the list
199199
->link()
200200
;
201-
201+
202202
// and click it
203203
$crawler = $client->click($link);
204204

@@ -451,25 +451,20 @@ You can also get the objects related to the latest request::
451451

452452
$crawler = $client->getCrawler();
453453

454-
If your requests are not insulated, you can also access the ``Container`` and
455-
the ``Kernel``::
456-
457-
$container = $client->getContainer();
458-
$kernel = $client->getKernel();
459-
460454
Accessing the Container
461455
~~~~~~~~~~~~~~~~~~~~~~~
462456

463-
It's highly recommended that a functional test only tests the Response. But
457+
It's highly recommended that a functional test only tests the response. But
464458
under certain very rare circumstances, you might want to access some internal
465459
objects to write assertions. In such cases, you can access the Dependency
466460
Injection Container::
467461

462+
// will be the same container used in your test, unless you're using
463+
// $client->insulate() or using real HTTP requests to test your application
468464
$container = $client->getContainer();
469465

470-
Be warned that this does not work if you insulate the client or if you use an
471-
HTTP layer. For a list of services available in your application, use the
472-
``debug:container`` console task.
466+
For a list of services available in your application, use the ``debug:container``
467+
console task.
473468

474469
.. versionadded:: 2.6
475470
Prior to Symfony 2.6, this command was called ``container:debug``.

0 commit comments

Comments
 (0)