TYPO3  7.6
StreamOutputTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
13 
16 
17 class StreamOutputTest extends \PHPUnit_Framework_TestCase
18 {
19  protected $stream;
20 
21  protected function setUp()
22  {
23  $this->stream = fopen('php://memory', 'a', false);
24  }
25 
26  protected function tearDown()
27  {
28  $this->stream = null;
29  }
30 
31  public function testConstructor()
32  {
33  $output = new StreamOutput($this->stream, Output::VERBOSITY_QUIET, true);
34  $this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument');
35  $this->assertTrue($output->isDecorated(), '__construct() takes the decorated flag as its second argument');
36  }
37 
42  public function testStreamIsRequired()
43  {
44  new StreamOutput('foo');
45  }
46 
47  public function testGetStream()
48  {
49  $output = new StreamOutput($this->stream);
50  $this->assertEquals($this->stream, $output->getStream(), '->getStream() returns the current stream');
51  }
52 
53  public function testDoWrite()
54  {
55  $output = new StreamOutput($this->stream);
56  $output->writeln('foo');
57  rewind($output->getStream());
58  $this->assertEquals('foo'.PHP_EOL, stream_get_contents($output->getStream()), '->doWrite() writes to the stream');
59  }
60 }