4
4
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5
5
* @license For full copyright and license information view LICENSE file distributed with this source code.
6
6
*/
7
+ declare (strict_types=1 );
7
8
8
9
namespace Ibexa \Tests \Bundle \IO \DependencyInjection ;
9
10
11
+ use Ibexa \Bundle \IO \DependencyInjection \ConfigurationFactory ;
10
12
use Matthias \SymfonyDependencyInjectionTest \PhpUnit \AbstractContainerBuilderTestCase ;
11
13
use Symfony \Component \Config \Definition \Builder \ArrayNodeDefinition ;
14
+ use Symfony \Component \DependencyInjection \Definition ;
12
15
13
16
/**
14
17
* Abstract class for testing ConfigurationFactory implementations.
17
20
*/
18
21
abstract class ConfigurationFactoryTestCase extends AbstractContainerBuilderTestCase
19
22
{
20
- /** @var \Ibexa\Bundle\IO\DependencyInjection\ConfigurationFactory */
21
- protected $ factory ;
23
+ protected ConfigurationFactory $ factory ;
22
24
23
25
protected function setUp (): void
24
26
{
@@ -27,24 +29,24 @@ protected function setUp(): void
27
29
$ this ->factory = $ this ->provideTestedFactory ();
28
30
}
29
31
30
- public function testGetParentServiceId ()
32
+ public function testGetParentServiceId (): void
31
33
{
32
34
self ::assertEquals (
33
35
$ this ->provideExpectedParentServiceId (),
34
36
$ this ->factory ->getParentServiceId ()
35
37
);
36
38
}
37
39
38
- public function testAddConfiguration ()
40
+ public function testAddConfiguration (): void
39
41
{
40
42
$ node = new ArrayNodeDefinition ('handler ' );
41
43
$ this ->factory ->addConfiguration ($ node );
42
- self ::assertInstanceOf (ArrayNodeDefinition::class, $ node );
44
+ self ::assertNotEmpty ( $ node-> getChildNodeDefinitions () );
43
45
44
46
// @todo customized testing of configuration node ?
45
47
}
46
48
47
- public function testConfigureHandler ()
49
+ public function testConfigureHandler (): void
48
50
{
49
51
$ handlerConfiguration =
50
52
$ this ->provideHandlerConfiguration () +
@@ -60,7 +62,7 @@ public function testConfigureHandler()
60
62
/**
61
63
* Registers the handler in the container, like the pass would have done.
62
64
*/
63
- private function registerHandler ($ name ): string
65
+ private function registerHandler (string $ name ): string
64
66
{
65
67
$ this ->setDefinition ($ this ->provideExpectedParentServiceId (), $ this ->provideParentServiceDefinition ());
66
68
$ handlerServiceId = sprintf ('%s.%s ' , $ this ->provideExpectedParentServiceId (), $ name );
@@ -71,10 +73,8 @@ private function registerHandler($name): string
71
73
72
74
/**
73
75
* Returns an instance of the tested factory.
74
- *
75
- * @return \Ibexa\Bundle\IO\DependencyInjection\ConfigurationFactory
76
76
*/
77
- abstract public function provideTestedFactory ();
77
+ abstract public function provideTestedFactory (): ConfigurationFactory ;
78
78
79
79
/**
80
80
* Returns the expected parent service id.
@@ -84,20 +84,18 @@ abstract public function provideExpectedParentServiceId();
84
84
/**
85
85
* Provides the parent service definition, as defined in the bundle's services definition.
86
86
* Required so that getArguments / replaceCalls work correctly.
87
- *
88
- * @return \Symfony\Component\DependencyInjection\Definition
89
87
*/
90
- abstract public function provideParentServiceDefinition ();
88
+ abstract public function provideParentServiceDefinition (): Definition ;
91
89
92
90
/**
93
91
* Provides the configuration array given to the handler, and initializes the container.
94
92
* The name and type index are automatically set to respectively 'my_handler' and 'my_handler_test'.
95
93
*
96
94
* The method can also configure the container via $this->container.
97
95
*
98
- * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
96
+ * @return array<string, string>
99
97
*/
100
- abstract public function provideHandlerConfiguration ();
98
+ abstract public function provideHandlerConfiguration (): array ;
101
99
102
100
/**
103
101
* Lets you test the handler definition after it was configured.
@@ -106,5 +104,5 @@ abstract public function provideHandlerConfiguration();
106
104
*
107
105
* @param string $handlerServiceId id of the service that was registered by the compiler pass
108
106
*/
109
- abstract public function validateConfiguredHandler ($ handlerServiceId );
107
+ abstract public function validateConfiguredHandler (string $ handlerServiceId ): void ;
110
108
}
0 commit comments