@@ -560,55 +560,53 @@ allows fetching both public and all non-removed private services::
560
560
For a list of services available in your application, use the ``debug:container ``
561
561
command.
562
562
563
- .. tip ::
563
+ If a private service is *never * used in your application (outside of your test),
564
+ it is *removed * from the container and cannot be accessed as described above. In
565
+ that case, you can create a public alias in the ``test `` environment and access
566
+ it via that alias:
564
567
565
- If a private service is *never * used in your application (outside of your test), it
566
- is *removed * from the container and cannot be accessed as described above. In that
567
- case, you can create a public alias in the ``test `` environment and access it
568
- via that alias:
569
-
570
- .. configuration-block ::
571
-
572
- .. code-block :: yaml
573
-
574
- # config/services_test.yaml
575
- services :
576
- # access the service in your test via
577
- # self::$container->get('test.App\Test\SomeTestHelper')
578
- test.App\Test\SomeTestHelper :
579
- # the id of the private service
580
- alias : ' App\Test\SomeTestHelper'
581
- public : true
582
-
583
- .. code-block :: xml
584
-
585
- <!-- config/services_test.xml -->
586
- <?xml version =" 1.0" encoding =" UTF-8" ?>
587
- <container xmlns =" http://symfony.com/schema/dic/services"
588
- xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
589
- xsi : schemaLocation =" http://symfony.com/schema/dic/services
590
- https://symfony.com/schema/dic/services/services-1.0.xsd" >
591
-
592
- <services >
593
- <!-- ... -->
568
+ .. configuration-block ::
569
+
570
+ .. code-block :: yaml
571
+
572
+ # config/services_test.yaml
573
+ services :
574
+ # access the service in your test via
575
+ # self::$container->get('test.App\Test\SomeTestHelper')
576
+ test.App\Test\SomeTestHelper :
577
+ # the id of the private service
578
+ alias : ' App\Test\SomeTestHelper'
579
+ public : true
580
+
581
+ .. code-block :: xml
582
+
583
+ <!-- config/services_test.xml -->
584
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
585
+ <container xmlns =" http://symfony.com/schema/dic/services"
586
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
587
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
588
+ https://symfony.com/schema/dic/services/services-1.0.xsd" >
594
589
595
- <service id =" test.App\Test\SomeTestHelper" alias =" App\Test\SomeTestHelper" public =" true" />
596
- </services >
597
- </container >
590
+ <services >
591
+ <!-- ... -->
598
592
599
- .. code-block :: php
593
+ <service id =" test.App\Test\SomeTestHelper" alias =" App\Test\SomeTestHelper" public =" true" />
594
+ </services >
595
+ </container >
596
+
597
+ .. code-block :: php
600
598
601
- // config/services_test.php
602
- namespace Symfony\Component\DependencyInjection\Loader\Configurator;
599
+ // config/services_test.php
600
+ namespace Symfony\Component\DependencyInjection\Loader\Configurator;
603
601
604
- use App\Service\MessageGenerator;
605
- use App\Updates\SiteUpdateManager;
602
+ use App\Service\MessageGenerator;
603
+ use App\Updates\SiteUpdateManager;
606
604
607
- return function(ContainerConfigurator $configurator) {
608
- // ...
605
+ return function(ContainerConfigurator $configurator) {
606
+ // ...
609
607
610
- $services->alias('test.App\Test\SomeTestHelper', 'App\Test\SomeTestHelper')->public();
611
- };
608
+ $services->alias('test.App\Test\SomeTestHelper', 'App\Test\SomeTestHelper')->public();
609
+ };
612
610
613
611
.. tip ::
614
612
0 commit comments