Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 97ea1f2

Browse filesBrowse files
committed
minor #17734 [FrameworkBundle] Allow setting private services with the test container (alexandre-daubois)
This PR was merged into the 6.3 branch. Discussion ---------- [FrameworkBundle] Allow setting private services with the test container Fixes #17733 Commits ------- f305d37 [FrameworkBundle] Allow setting private services with the test container
2 parents 0bdf372 + f305d37 commit 97ea1f2
Copy full SHA for 97ea1f2

File tree

1 file changed

+5
-44
lines changed
Filter options

1 file changed

+5
-44
lines changed

‎testing.rst

Copy file name to clipboardExpand all lines: testing.rst
+5-44Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.