|
6 | 6 | use Http\Client\Common\Plugin;
|
7 | 7 | use Http\Client\Common\PluginClient;
|
8 | 8 | use Http\Discovery\StreamFactoryDiscovery;
|
| 9 | +use Http\Discovery\UriFactoryDiscovery; |
9 | 10 | use Http\HttplugBundle\Collector\Collector;
|
10 | 11 | use Http\HttplugBundle\Collector\Formatter;
|
11 | 12 | use Http\HttplugBundle\Collector\ProfileClient;
|
@@ -82,6 +83,25 @@ public function testProfilingWhenPluginThrowException()
|
82 | 83 | }
|
83 | 84 | }
|
84 | 85 |
|
| 86 | + public function testProfiling() |
| 87 | + { |
| 88 | + $client = $this->createClient([ |
| 89 | + new Plugin\AddHostPlugin(UriFactoryDiscovery::find()->createUri('https://example.com')), |
| 90 | + new Plugin\RedirectPlugin(), |
| 91 | + new Plugin\RetryPlugin(), |
| 92 | + ]); |
| 93 | + |
| 94 | + $client->sendRequest(new Request('GET', '/')); |
| 95 | + |
| 96 | + $this->assertCount(1, $this->collector->getStacks()); |
| 97 | + $stack = $this->collector->getStacks()[0]; |
| 98 | + $this->assertCount(3, $stack->getProfiles()); |
| 99 | + $this->assertEquals('GET', $stack->getRequestMethod()); |
| 100 | + $this->assertEquals('https', $stack->getRequestScheme()); |
| 101 | + $this->assertEquals('/', $stack->getRequestTarget()); |
| 102 | + $this->assertEquals('example.com', $stack->getRequestHost()); |
| 103 | + } |
| 104 | + |
85 | 105 | private function createClient(array $plugins, $clientName = 'Acme', array $clientOptions = [])
|
86 | 106 | {
|
87 | 107 | $plugins = array_map(function (Plugin $plugin) {
|
|
0 commit comments