Skip to content

Commit cdfe849

Browse files
committed
minor #37209 [DI][Framework] Use PHP instead of XML for test config (GaryPEGEOT)
This PR was squashed before being merged into the 5.2-dev branch. Discussion ---------- [DI][Framework] Use PHP instead of XML for test config | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | Partially #37186 | License | MIT See #37186 Commits ------- 36cc98228e [DI][Framework] Use PHP instead of XML for test config
2 parents 6306f93 + 5e6866e commit cdfe849

File tree

3 files changed

+58
-42
lines changed

3 files changed

+58
-42
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public function load(array $configs, ContainerBuilder $container)
259259
}
260260

261261
if (!empty($config['test'])) {
262-
$loader->load('test.xml');
262+
$phpLoader->load('test.php');
263263

264264
if (!class_exists(AbstractBrowser::class)) {
265265
$container->removeDefinition('test.client');

Resources/config/test.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
13+
14+
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
15+
use Symfony\Bundle\FrameworkBundle\Test\TestContainer;
16+
use Symfony\Component\BrowserKit\CookieJar;
17+
use Symfony\Component\BrowserKit\History;
18+
use Symfony\Component\DependencyInjection\ServiceLocator;
19+
use Symfony\Component\HttpKernel\EventListener\TestSessionListener;
20+
21+
return static function (ContainerConfigurator $container) {
22+
$container->parameters()->set('test.client.parameters', []);
23+
24+
$container->services()
25+
->set('test.client', KernelBrowser::class)
26+
->args([
27+
service('kernel'),
28+
param('test.client.parameters'),
29+
service('test.client.history'),
30+
service('test.client.cookiejar'),
31+
])
32+
->share(false)
33+
->public()
34+
35+
->set('test.client.history', History::class)->share(false)
36+
->set('test.client.cookiejar', CookieJar::class)->share(false)
37+
38+
->set('test.session.listener', TestSessionListener::class)
39+
->args([
40+
service_locator([
41+
'session' => service('session')->ignoreOnInvalid(),
42+
]),
43+
])
44+
->tag('kernel.event_subscriber')
45+
46+
->set('test.service_container', TestContainer::class)
47+
->args([
48+
service('kernel'),
49+
'test.private_services_locator',
50+
])
51+
->public()
52+
53+
->set('test.private_services_locator', ServiceLocator::class)
54+
->args([abstract_arg('callable collection')])
55+
->public()
56+
;
57+
};

Resources/config/test.xml

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)