File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -508,18 +508,30 @@ You can also get the objects related to the latest request::
508508Accessing the Container
509509~~~~~~~~~~~~~~~~~~~~~~~
510510
511+ .. versionadded :: 4.1
512+
513+ The ``self::$container `` property was introduced in Symfony 4.1.
514+
511515It's highly recommended that a functional test only tests the response. But
512516under certain very rare circumstances, you might want to access some internal
513- objects to write assertions. In such cases, you can access the Dependency
514- Injection Container::
517+ objects to write assertions. In such cases, you can access your services via
518+ a special property on the test class. Because services are private by default,
519+ this property holds a special container, which allows fetching public and all
520+ non-removed private services::
515521
516- // will be the same container used in your test, unless you're using
522+ // gives access to the same services used in your test, unless you're using
517523 // $client->insulate() or using real HTTP requests to test your application
518- $container = $client->getContainer() ;
524+ $container = self::$container ;
519525
520526For a list of services available in your application, use the ``debug:container ``
521527command.
522528
529+ .. tip ::
530+
531+ The special container that gives access to private services exists only in
532+ the ``test `` environment and is itself a service that you can accessed from
533+ the real container using the ``test.service_container `` id.
534+
523535.. tip ::
524536
525537 If the information you need to check is available from the profiler, use
You can’t perform that action at this time.
0 commit comments