@@ -23,7 +23,7 @@ public static function setUpBeforeClass(): void
23
23
/**
24
24
* @dataProvider processDataProvider
25
25
*/
26
- public function testProcess (string $ httpClientServiceId ): void
26
+ public function testProcess (? string $ httpClientServiceId ): void
27
27
{
28
28
$ container = $ this ->createContainerBuilder (true , true , $ httpClientServiceId );
29
29
$ container ->compile ();
@@ -54,6 +54,14 @@ public function processDataProvider(): \Generator
54
54
];
55
55
}
56
56
57
+ public function testProcessDoesNothingIfHttpClientServiceCannotBeFound (): void
58
+ {
59
+ $ container = $ this ->createContainerBuilder (true , true , null );
60
+ $ container ->compile ();
61
+
62
+ $ this ->assertFalse ($ container ->hasDefinition ('http_client ' ));
63
+ }
64
+
57
65
/**
58
66
* @dataProvider processDoesNothingIfConditionsForEnablingTracingAreMissingDataProvider
59
67
*/
@@ -86,7 +94,7 @@ public function processDoesNothingIfConditionsForEnablingTracingAreMissingDataPr
86
94
];
87
95
}
88
96
89
- private function createContainerBuilder (bool $ isTracingEnabled , bool $ isHttpClientTracingEnabled , string $ httpClientServiceId ): ContainerBuilder
97
+ private function createContainerBuilder (bool $ isTracingEnabled , bool $ isHttpClientTracingEnabled , ? string $ httpClientServiceId ): ContainerBuilder
90
98
{
91
99
$ container = new ContainerBuilder ();
92
100
$ container ->addCompilerPass (new HttpClientTracingPass ());
@@ -96,8 +104,10 @@ private function createContainerBuilder(bool $isTracingEnabled, bool $isHttpClie
96
104
$ container ->register (HubInterface::class, HubInterface::class)
97
105
->setPublic (true );
98
106
99
- $ container ->register ($ httpClientServiceId , HttpClientInterface::class)
100
- ->setPublic (true );
107
+ if (null !== $ httpClientServiceId ) {
108
+ $ container ->register ($ httpClientServiceId , HttpClientInterface::class)
109
+ ->setPublic (true );
110
+ }
101
111
102
112
return $ container ;
103
113
}
0 commit comments