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 dded8a9

Browse filesBrowse files
[FrameworkBundle] Allow setting private services with the test container
1 parent 740e44f commit dded8a9
Copy full SHA for dded8a9

File tree

1 file changed

+4
-46
lines changed
Filter options

1 file changed

+4
-46
lines changed

‎testing.rst

Copy file name to clipboardExpand all lines: testing.rst
+4-46Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ concrete one::
311311
])
312312
;
313313

314-
// the following line won't work unless the alias is made public
315314
$container->set(NewsRepositoryInterface::class, $newsRepository);
316315

317316
// will be injected the mocked repository
@@ -321,52 +320,11 @@ concrete one::
321320
}
322321
}
323322

324-
In order to make the alias public, you will need to update configuration for
325-
the ``test`` environment as follows:
323+
.. deprecated:: 6.3
326324

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;
362-
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-
};
325+
Prior to Symfony 6.3, private aliases had to be declared public in the
326+
configuration files for the ``test`` environment. This is now unnecessary
327+
and deprecated.
370328

371329
.. _testing-databases:
372330

0 commit comments

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