|
10 | 10 | use Http\HttplugBundle\Collector\ProfilePlugin;
|
11 | 11 | use Http\HttplugBundle\Collector\StackPlugin;
|
12 | 12 | use Nyholm\NSA;
|
| 13 | +use Psr\Http\Client\ClientInterface; |
| 14 | +use Psr\Http\Message\ResponseInterface; |
13 | 15 | use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
14 | 16 | use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
15 | 17 | use Symfony\Component\HttpFoundation\Request;
|
@@ -77,6 +79,28 @@ public function testProfilingDecoration()
|
77 | 79 | $this->assertInstanceOf(ProfilePlugin::class, $plugins[4]);
|
78 | 80 | }
|
79 | 81 |
|
| 82 | + public function testProfilingPsr18Decoration() |
| 83 | + { |
| 84 | + if (!interface_exists(ClientInterface::class)) { |
| 85 | + $this->markTestSkipped('PSR-18 is not installed'); |
| 86 | + } |
| 87 | + |
| 88 | + static::bootKernel(['debug' => true, 'environment' => 'psr18']); |
| 89 | + $container = static::$kernel->getContainer(); |
| 90 | + |
| 91 | + $client = $container->get('httplug.client.my_psr18'); |
| 92 | + $this->assertInstanceOf(PluginClient::class, $client); |
| 93 | + $profileClient = NSA::getProperty($client, 'client'); |
| 94 | + $this->assertInstanceOf(ProfileClient::class, $profileClient); |
| 95 | + |
| 96 | + $flexibleClient = NSA::getProperty($profileClient, 'client'); |
| 97 | + $psr18Client = NSA::getProperty($flexibleClient, 'httpClient'); |
| 98 | + $this->assertInstanceOf(ClientInterface::class, $psr18Client); |
| 99 | + |
| 100 | + $response = $client->sendRequest(new \GuzzleHttp\Psr7\Request('GET', 'https://example.com')); |
| 101 | + $this->assertInstanceOf(ResponseInterface::class, $response); |
| 102 | + } |
| 103 | + |
80 | 104 | /**
|
81 | 105 | * {@inheritdoc}
|
82 | 106 | */
|
|
0 commit comments