public function testConstructor()
 {
     try {
         $output = new StreamOutput('foo');
         $this->fail('__construct() throws an \\InvalidArgumentException if the first argument is not a stream');
     } catch (\InvalidArgumentException $e) {
     }
     $output = new StreamOutput($this->stream, Output::VERBOSITY_QUIET, true);
     $this->assertEquals($output->getVerbosity(), Output::VERBOSITY_QUIET, '__construct() takes the verbosity as its first argument');
     $this->assertEquals($output->isDecorated(), true, '__construct() takes the decorated flag as its second argument');
 }
 public function testConstructor()
 {
     try {
         $output = new StreamOutput('foo');
         $this->fail('__construct() throws an \\InvalidArgumentException if the first argument is not a stream');
     } catch (\Exception $e) {
         $this->assertInstanceOf('\\InvalidArgumentException', $e, '__construct() throws an \\InvalidArgumentException if the first argument is not a stream');
         $this->assertEquals('The StreamOutput class needs a stream as its first argument.', $e->getMessage());
     }
     $output = new StreamOutput($this->stream, Output::VERBOSITY_QUIET, true);
     $this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument');
     $this->assertTrue($output->isDecorated(), '__construct() takes the decorated flag as its second argument');
 }
$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');