|
10 | 10 | use Http\Message\StreamFactory; |
11 | 11 | use Http\Message\UriFactory; |
12 | 12 | use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase; |
| 13 | +use Matthias\SymfonyDependencyInjectionTest\PhpUnit\ContainerBuilderHasAliasConstraint; |
| 14 | +use PHPUnit\Framework\Constraint\LogicalNot; |
13 | 15 | use Symfony\Component\DependencyInjection\Definition; |
14 | 16 |
|
15 | 17 | /** |
@@ -71,4 +73,39 @@ public function testNoDiscoveryFallbacks() |
71 | 73 | $clientDefinition = $this->container->getDefinition('httplug.client.default'); |
72 | 74 | $this->assertEquals([HttpClientDiscovery::class, 'find'], $clientDefinition->getFactory()); |
73 | 75 | } |
| 76 | + |
| 77 | + public function testEnableAutowiring() |
| 78 | + { |
| 79 | + $this->load([ |
| 80 | + 'default_client_autowiring' => true, |
| 81 | + ]); |
| 82 | + |
| 83 | + $this->assertContainerBuilderHasService('httplug.client.default'); |
| 84 | + $this->assertContainerBuilderHasService('httplug.async_client.default'); |
| 85 | + $this->assertContainerBuilderHasAlias(HttpClient::class); |
| 86 | + $this->assertContainerBuilderHasAlias(HttpAsyncClient::class); |
| 87 | + } |
| 88 | + |
| 89 | + public function testDisableAutowiring() |
| 90 | + { |
| 91 | + if (PHP_VERSION_ID <= 70000) { |
| 92 | + $this->markTestSkipped(); |
| 93 | + } |
| 94 | + |
| 95 | + $this->load([ |
| 96 | + 'default_client_autowiring' => false, |
| 97 | + ]); |
| 98 | + |
| 99 | + $this->assertContainerBuilderHasService('httplug.client.default'); |
| 100 | + $this->assertContainerBuilderHasService('httplug.async_client.default'); |
| 101 | + |
| 102 | + self::assertThat( |
| 103 | + $this->container, |
| 104 | + new LogicalNot(new ContainerBuilderHasAliasConstraint(HttpClient::class)) |
| 105 | + ); |
| 106 | + self::assertThat( |
| 107 | + $this->container, |
| 108 | + new LogicalNot(new ContainerBuilderHasAliasConstraint(HttpAsyncClient::class)) |
| 109 | + ); |
| 110 | + } |
74 | 111 | } |
0 commit comments