@@ -49,12 +49,17 @@ Basically you will be testing your extension's load method, which will look some
4949``` php
5050<?php
5151
52+ use Symfony\Component\Config\FileLocator;
53+ use Symfony\Component\DependencyInjection\ContainerBuilder;
54+ use Symfony\Component\DependencyInjection\Extension\Extension;
55+ use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
56+
5257class MyExtension extends Extension
5358{
5459 public function load(array $config, ContainerBuilder $container)
5560 {
56- $loader = new XmlFileLoader ($container, new FileLocator(__DIR__));
57- $loader->load('services.xml ');
61+ $loader = new PhpFileLoader ($container, new FileLocator(__DIR__));
62+ $loader->load('services.php ');
5863
5964 // maybe process the configuration values in $config, then:
6065
@@ -68,11 +73,12 @@ So in the test case you should test that after loading the container, the parame
6873``` php
6974<?php
7075
76+ use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase;
77+ use PHPUnit\Framework\Attributes\Test;
78+
7179class MyExtensionTest extends AbstractExtensionTestCase
7280{
73- /**
74- * @test
75- */
81+ #[Test]
7682 public function after_loading_the_correct_parameter_has_been_set()
7783 {
7884 $this->load();
@@ -87,11 +93,12 @@ To test the effect of different configuration values, use the first argument of
8793``` php
8894<?php
8995
96+ use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase;
97+ use PHPUnit\Framework\Attributes\Test;
98+
9099class MyExtensionTest extends AbstractExtensionTestCase
91100{
92- /**
93- * @test
94- */
101+ #[Test]
95102 public function after_loading_the_correct_parameter_has_been_set()
96103 {
97104 $this->load(['my' => ['enabled' => 'false']);
@@ -113,6 +120,7 @@ To test a compiler pass, create a test class and extend from
113120<?php
114121
115122use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase;
123+ use Symfony\Component\DependencyInjection\ContainerBuilder;
116124
117125class MyCompilerPassTest extends AbstractCompilerPassTestCase
118126{
@@ -132,11 +140,13 @@ instance.
132140``` php
133141<?php
134142
143+ use PHPUnit\Framework\Attributes\Test;
144+ use Symfony\Component\DependencyInjection\Definition;
145+ use Symfony\Component\DependencyInjection\Reference;
146+
135147class MyCompilerPassTest extends AbstractCompilerPassTestCase
136148{
137- /**
138- * @test
139- */
149+ #[Test]
140150 public function if_compiler_pass_collects_services_by_adding_method_calls_these_will_exist()
141151 {
142152 $collectingService = new Definition();
@@ -250,6 +260,16 @@ twig:
250260 extensions : ['twig.extension.foo']
251261` ` `
252262
263+ ` ` ` php
264+ <?php // in Fixtures/config.php
265+
266+ return App::config([
267+ ' twig' => [
268+ ' extensions' => ['twig.extension.foo']
269+ ],
270+ ]);
271+ ```
272+
253273``` xml
254274<!-- in Fixtures/config.xml -->
255275<container >
@@ -261,15 +281,13 @@ twig:
261281
262282``` php
263283<?php
264- ...
284+
285+ use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionConfigurationTestCase;
286+ use PHPUnit\Framework\Attributes\Test;
265287
266288class ConfigurationTest extends AbstractExtensionConfigurationTestCase
267289{
268- ...
269-
270- /**
271- * @test
272- */
290+ #[Test]
273291 public function it_converts_extension_elements_to_extensions()
274292 {
275293 $expectedConfiguration = [
0 commit comments