Skip to content

Commit f507c1a

Browse files
fbourigaultNyholm
authored andcommitted
add discovery functional tests when discovery is forced or disabled (#184)
1 parent 327df14 commit f507c1a

File tree

6 files changed

+43
-8
lines changed

6 files changed

+43
-8
lines changed

Tests/Functional/DiscoveredClientsTest.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,32 @@ public function testDiscoveredAsyncClientWithProfilingEnabled()
7171
$this->assertEquals('auto_discovered_async', NSA::getProperty($plugins[0], 'client'));
7272
}
7373

74-
private function getContainer($debug)
74+
public function testDisabledDiscovery()
7575
{
76-
static::bootKernel(['debug' => $debug]);
76+
$container = $this->getContainer(true, 'discovery_disabled');
77+
78+
$this->assertFalse($container->has('httplug.auto_discovery.auto_discovered_client'));
79+
$this->assertFalse($container->has('httplug.auto_discovery.auto_discovered_async'));
80+
$this->assertFalse($container->has('httplug.strategy'));
81+
}
82+
83+
public function testForcedDiscovery()
84+
{
85+
$container = $this->getContainer(true, 'discovery_forced');
86+
87+
$this->assertFalse($container->has('httplug.auto_discovery.auto_discovered_client'));
88+
$this->assertFalse($container->has('httplug.auto_discovery.auto_discovered_async'));
89+
$this->assertTrue($container->has('httplug.strategy'));
90+
91+
$strategy = $container->get('httplug.strategy');
92+
93+
$this->assertEquals($container->get('httplug.client.acme'), NSA::getProperty($strategy, 'client'));
94+
$this->assertEquals($container->get('httplug.client.acme'), NSA::getProperty($strategy, 'asyncClient'));
95+
}
96+
97+
private function getContainer($debug, $environment = 'test')
98+
{
99+
static::bootKernel(['debug' => $debug, 'environment' => $environment]);
77100

78101
return static::$kernel->getContainer();
79102
}

Tests/Resources/app/AppKernel.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ public function registerBundles()
2828
*/
2929
public function registerContainerConfiguration(LoaderInterface $loader)
3030
{
31-
$this->isDebug()
32-
? $loader->load(__DIR__.'/config/config_debug.yml')
33-
: $loader->load(__DIR__.'/config/config.yml');
31+
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
32+
if ($this->isDebug()) {
33+
$loader->load(__DIR__.'/config/config_debug.yml');
34+
}
3435
}
3536

3637
/**
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
imports:
2-
- { resource: config.yml }
3-
41
framework:
52
profiler: ~
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
imports:
2+
- { resource: config_test.yml }
3+
4+
httplug:
5+
discovery:
6+
client: ~
7+
async_client: ~
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
imports:
2+
- { resource: config_test.yml }
3+
4+
httplug:
5+
discovery:
6+
client: httplug.client.acme
7+
async_client: httplug.client.acme

0 commit comments

Comments
 (0)