Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / symfony / console / Symfony / Component / Console / Tests / Output / StreamOutputTest.php
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
12 namespace Symfony\Component\Console\Tests\Output;
13
14 use Symfony\Component\Console\Output\Output;
15 use Symfony\Component\Console\Output\StreamOutput;
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         try {
34             $output = new StreamOutput('foo');
35             $this->fail('__construct() throws an \InvalidArgumentException if the first argument is not a stream');
36         } catch (\Exception $e) {
37             $this->assertInstanceOf('\InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException if the first argument is not a stream');
38             $this->assertEquals('The StreamOutput class needs a stream as its first argument.', $e->getMessage());
39         }
40
41         $output = new StreamOutput($this->stream, Output::VERBOSITY_QUIET, true);
42         $this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument');
43         $this->assertTrue($output->isDecorated(), '__construct() takes the decorated flag as its second argument');
44     }
45
46     public function testGetStream()
47     {
48         $output = new StreamOutput($this->stream);
49         $this->assertEquals($this->stream, $output->getStream(), '->getStream() returns the current stream');
50     }
51
52     public function testDoWrite()
53     {
54         $output = new StreamOutput($this->stream);
55         $output->writeln('foo');
56         rewind($output->getStream());
57         $this->assertEquals('foo'.PHP_EOL, stream_get_contents($output->getStream()), '->doWrite() writes to the stream');
58     }
59 }