Skip to content

Commit 94fce51

Browse files
committed
c
1 parent dd01464 commit 94fce51

8 files changed

+24
-27
lines changed

src/Collector/Collector.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
* @author Fabien Bourigault <[email protected]>
1919
*
2020
* @internal
21-
*
22-
* @final
2321
*/
2422
final class Collector extends DataCollector
2523
{

src/Collector/Formatter.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
* @author Fabien Bourigault <[email protected]>
1919
*
2020
* @internal
21-
*
22-
* @final
2321
*/
2422
final class Formatter implements MessageFormatter
2523
{

src/Collector/ProfileClient.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@
2121
* @author Fabien Bourigault <[email protected]>
2222
*
2323
* @internal
24-
*
25-
* @final
2624
*/
27-
final class ProfileClient implements ClientInterace, HttpAsyncClient
25+
final class ProfileClient implements ClientInterface, HttpAsyncClient
2826
{
2927
use VersionBridgeClient;
3028

src/Collector/ProfileClientFactory.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
* @author Fabien Bourigault <[email protected]>
1717
*
1818
* @internal
19-
*
20-
* @final
2119
*/
2220
final class ProfileClientFactory implements ClientFactory
2321
{

src/Collector/ProfilePlugin.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
* @author Fabien Bourigault <[email protected]>
1616
*
1717
* @internal
18-
*
19-
* @final
2018
*/
2119
final class ProfilePlugin implements Plugin
2220
{

src/Collector/StackPlugin.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
* @author Fabien Bourigault <[email protected]>
1616
*
1717
* @internal
18-
*
19-
* @final
2018
*/
2119
final class StackPlugin implements Plugin
2220
{

tests/Unit/Collector/ProfilePluginTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Http\HttplugBundle\Collector\ProfilePlugin;
1414
use Http\HttplugBundle\Collector\Stack;
1515
use Http\Message\Formatter as MessageFormatter;
16+
use Http\Message\Formatter\SimpleFormatter;
1617
use Http\Promise\FulfilledPromise;
1718
use Http\Promise\Promise;
1819
use Http\Promise\RejectedPromise;
@@ -42,7 +43,7 @@ class ProfilePluginTest extends TestCase
4243
public function setUp(): void
4344
{
4445
$this->collector = new Collector();
45-
$messageFormatter = $this->createMock(MessageFormatter::class);
46+
$messageFormatter = $this->createMock(SimpleFormatter::class);
4647
$this->formatter = new Formatter($messageFormatter, $this->createMock(MessageFormatter::class));
4748

4849
$this->plugin = $this->getMockBuilder(Plugin::class)->getMock();
@@ -74,7 +75,7 @@ public function setUp(): void
7475
$this->subject = new ProfilePlugin(
7576
$this->plugin,
7677
$this->collector,
77-
$this->formatter
78+
$this->formatter,
7879
);
7980
}
8081

@@ -131,8 +132,8 @@ public function testOnRejected(): void
131132
});
132133

133134
$this->assertEquals($this->exception, $promise->wait());
134-
$profile = $this->currentStack->getProfiles()[0];
135135
$this->expectException(TransferException::class);
136+
$profile = $this->currentStack->getProfiles()[0];
136137
$profile->getResponse();
137138
}
138139
}

tests/Unit/Collector/StackPluginTest.php

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Http\HttplugBundle\Collector\Formatter;
1212
use Http\HttplugBundle\Collector\StackPlugin;
1313
use Http\Message\Formatter as MessageFormatter;
14+
use Http\Message\Formatter\SimpleFormatter;
1415
use Http\Promise\FulfilledPromise;
1516
use Http\Promise\RejectedPromise;
1617
use PHPUnit\Framework\Error\Warning;
@@ -48,7 +49,7 @@ class StackPluginTest extends TestCase
4849
public function setUp(): void
4950
{
5051
$this->collector = new Collector();
51-
$messageFormatter = $this->createMock(MessageFormatter::class);
52+
$messageFormatter = $this->createMock(SimpleFormatter::class);
5253
$this->formatter = new Formatter($messageFormatter, $this->createMock(MessageFormatter::class));
5354
$this->request = new Request('GET', '/');
5455
$this->response = new Response();
@@ -76,9 +77,11 @@ public function testStackIsInitialized(): void
7677
$this->subject->handleRequest($this->request, $next, function (): void {
7778
});
7879

79-
$stack = $this->collector->getActiveStack();
80-
$this->assertEquals('default', $stack->getClient());
81-
$this->assertEquals('FormattedRequest', $stack->getRequest());
80+
$this->assertNull($this->collector->getActiveStack());
81+
$stacks = $this->collector->getStacks();
82+
$this->assertCount(1, $stacks);
83+
$this->assertEquals('default', $stacks[0]->getClient());
84+
$this->assertEquals('FormattedRequest', $stacks[0]->getRequest());
8285
}
8386

8487
public function testOnFulfilled(): void
@@ -88,9 +91,10 @@ public function testOnFulfilled(): void
8891
$promise = $this->subject->handleRequest($this->request, $next, function (): void {
8992
});
9093

91-
$this->assertEquals($this->response, $promise->wait());
92-
$currentStack = $this->collector->getActiveStack();
93-
$this->assertEquals('FormattedResponse', $currentStack->getResponse());
94+
$this->assertNull($this->collector->getActiveStack());
95+
$stacks = $this->collector->getStacks();
96+
$this->assertCount(1, $stacks);
97+
$this->assertEquals('FormattedResponse', $stacks[0]->getResponse());
9498
}
9599

96100
public function testOnRejected(): void
@@ -100,10 +104,14 @@ public function testOnRejected(): void
100104
$promise = $this->subject->handleRequest($this->request, $next, function (): void {
101105
});
102106

103-
$this->assertEquals($this->exception, $promise->wait());
104-
$currentStack = $this->collector->getActiveStack();
105-
$this->assertEquals('FormattedResponse', $currentStack->getResponse());
106-
$this->assertTrue($currentStack->isFailed());
107+
$this->assertNull($this->collector->getActiveStack());
108+
$stacks = $this->collector->getStacks();
109+
$this->assertCount(1, $stacks);
110+
$this->assertEquals('FormattedResponse', $stacks[0]->getResponse());
111+
$this->assertTrue($stacks[0]->isFailed());
112+
113+
$this->expectException(\Exception::class);
114+
$promise->wait();
107115
}
108116

109117
public function testOnException(): void

0 commit comments

Comments
 (0)