Skip to content

Commit bdce237

Browse files
committed
add working test for normal profiling
1 parent 2f4b1bd commit bdce237

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Tests/Functional/ProfilingTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Http\Client\Common\Plugin;
77
use Http\Client\Common\PluginClient;
88
use Http\Discovery\StreamFactoryDiscovery;
9+
use Http\Discovery\UriFactoryDiscovery;
910
use Http\HttplugBundle\Collector\Collector;
1011
use Http\HttplugBundle\Collector\Formatter;
1112
use Http\HttplugBundle\Collector\ProfileClient;
@@ -82,6 +83,25 @@ public function testProfilingWhenPluginThrowException()
8283
}
8384
}
8485

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+
85105
private function createClient(array $plugins, $clientName = 'Acme', array $clientOptions = [])
86106
{
87107
$plugins = array_map(function (Plugin $plugin) {

0 commit comments

Comments
 (0)