@@ -321,52 +321,13 @@ concrete one::
321321 }
322322 }
323323
324- In order to make the alias public, you will need to update configuration for
325- the `` test `` environment as follows:
324+ No further configuration in required, as the test service container is a special one
325+ that allows you to interact with private services and aliases.
326326
327- .. configuration-block ::
328-
329- .. code-block :: yaml
330-
331- # config/services_test.yaml
332- services :
333- # redefine the alias as it should be while making it public
334- App\Contracts\Repository\NewsRepositoryInterface :
335- alias : App\Repository\NewsRepository
336- public : true
337-
338- .. code-block :: xml
339-
340- <!-- config/services_test.xml -->
341- <?xml version =" 1.0" encoding =" UTF-8" ?>
342- <container xmlns =" http://symfony.com/schema/dic/services"
343- xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
344- xsi : schemaLocation =" http://symfony.com/schema/dic/services
345- https://symfony.com/schema/dic/services/services-1.0.xsd
346- " >
347- <services >
348- <!-- redefine the alias as it should be while making it public -->
349- <service id =" App\Contracts\Repository\NewsRepositoryInterface"
350- alias =" App\Repository\NewsRepository"
351- />
352- </services >
353- </container >
354-
355- .. code-block :: php
356-
357- // config/services_test.php
358- namespace Symfony\Component\DependencyInjection\Loader\Configurator;
359-
360- use App\Contracts\Repository\NewsRepositoryInterface;
361- use App\Repository\NewsRepository;
327+ .. versionadded :: 6.3
362328
363- return static function (ContainerConfigurator $containerConfigurator) {
364- $containerConfigurator->services()
365- // redefine the alias as it should be while making it public
366- ->alias(NewsRepositoryInterface::class, NewsRepository::class)
367- ->public()
368- ;
369- };
329+ The possibility to set a private service with the test service container without
330+ declaring the alias as public was introduced in Symfony 6.3.
370331
371332.. _testing-databases :
372333
0 commit comments