/** @test */ public function endShouldWriteDataBeforeClosing() { $through = new ThroughStream(); $through->on('data', $this->expectCallableOnceWith('foo')); $through->end('foo'); $this->assertFalse($through->isReadable()); $this->assertFalse($through->isWritable()); }
public function testHandleEndEnsureNoError() { $ended = false; $stream = new ThroughStream(); $response = new ChunkedStreamDecoder($stream); $response->on('error', function ($error) { $this->fail((string) $error); }); $response->on('end', function () use(&$ended) { $ended = true; }); $stream->write("4\r\nWiki\r\n"); $stream->write("0\r\n\r\n"); $stream->end(); $this->assertTrue($ended); }