public function testApiWrite_WritesDataCorrectly()
{
$stream = $this->createStreamMock();
$resource = $stream->getResource();
$expectedData = "foobar\n";
$capturedData = null;
$stream->on('drain', $this->expectCallableOnce());
$stream->write($expectedData);
$stream->rewind();
$this->assertSame($expectedData, fread($resource, $stream->getBufferSize()));
}