Skip to content

Commit 48e6c7c

Browse files
committed
Update tests
1 parent 61bd6b8 commit 48e6c7c

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

tests/Feature/StreamResponseTest.php

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44

55
namespace Spiral\RoadRunner\Tests\Http\Feature;
66

7+
use Exception;
78
use PHPUnit\Framework\TestCase;
89
use Spiral\Goridge\SocketRelay;
910
use Spiral\RoadRunner\Http\Exception\StreamStoppedException;
1011
use Spiral\RoadRunner\Http\HttpWorker;
12+
use Spiral\RoadRunner\Message\Command\GetProcessId;
1113
use Spiral\RoadRunner\Payload;
1214
use Spiral\RoadRunner\Tests\Http\Server\Command\BaseCommand;
1315
use Spiral\RoadRunner\Tests\Http\Server\Command\StreamStop;
@@ -94,10 +96,31 @@ public function testStopStreamResponse(): void
9496
self::assertSame(\implode("\n", ['Hel', 'lo,']), \trim(ServerRunner::getBuffer()));
9597
}
9698

99+
public function testExceptionInGenerator(): void
100+
{
101+
$httpWorker = $this->makeHttpWorker();
102+
103+
// Flush buffer
104+
ServerRunner::getBuffer();
105+
106+
$httpWorker->respond(
107+
200,
108+
(function () {
109+
yield 'Hel';
110+
yield 'lo,';
111+
throw new Exception('test');
112+
})(),
113+
);
114+
115+
116+
\usleep(100_000);
117+
self::assertSame(\implode("\n", ['Hel', 'lo,']), \trim(ServerRunner::getBuffer()));
118+
}
119+
97120
/**
98121
* StopStream should be ignored if stream is already ended.
99122
* Commented because doesn't pass in CI
100-
* todo: check after RoadRunner Stream Response release
123+
*/
101124
public function testStopStreamAfterStreamEnd(): void
102125
{
103126
$httpWorker = $this->makeHttpWorker();
@@ -116,11 +139,14 @@ public function testStopStreamAfterStreamEnd(): void
116139
$this->assertFalse($this->getWorker()->hasPayload(\Spiral\RoadRunner\Message\Command\StreamStop::class));
117140
$this->sendCommand(new StreamStop());
118141
\usleep(200_000);
119-
self::assertSame(\implode("\n", ['Hello', 'World!']), \trim(ServerRunner::getBuffer()));
142+
$this->assertSame(\implode("\n", ['Hello', 'World!']), \trim(ServerRunner::getBuffer()));
120143
$this->assertTrue($this->getWorker()->hasPayload(\Spiral\RoadRunner\Message\Command\StreamStop::class));
144+
145+
$this->getWorker()->getPayload(\Spiral\RoadRunner\Message\Command\StreamStop::class);
146+
$this->getWorker()->getPayload(GetProcessId::class);
147+
121148
$this->assertFalse($this->getWorker()->hasPayload());
122149
}
123-
*/
124150

125151
private function getRelay(): SocketRelay
126152
{

0 commit comments

Comments
 (0)