public function testDoWrite()
 {
     $output = new StreamOutput($this->stream);
     $output->writeln('foo');
     rewind($output->getStream());
     $this->assertEquals('foo' . PHP_EOL, stream_get_contents($output->getStream()), '->doWrite() writes to the stream');
 }
$stream = fopen('php://memory', 'a', false);

// __construct()
$t->diag('__construct()');

try
{
  $output = new StreamOutput('foo');
  $t->fail('__construct() throws an \InvalidArgumentException if the first argument is not a stream');
}
catch (\InvalidArgumentException $e)
{
  $t->pass('__construct() throws an \InvalidArgumentException if the first argument is not a stream');
}

$output = new StreamOutput($stream, Output::VERBOSITY_QUIET, true);
$t->is($output->getVerbosity(), Output::VERBOSITY_QUIET, '__construct() takes the verbosity as its first argument');
$t->is($output->isDecorated(), true, '__construct() takes the decorated flag as its second argument');

// ->getStream()
$t->diag('->getStream()');
$output = new StreamOutput($stream);
$t->is($output->getStream(), $stream, '->getStream() returns the current stream');

// ->doWrite()
$t->diag('->doWrite()');
$output = new StreamOutput($stream);
$output->writeln('foo');
rewind($output->getStream());
$t->is(stream_get_contents($output->getStream()), "foo\n", '->doWrite() writes to the stream');