Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / symfony / console / Symfony / Component / Console / Tests / Tester / ApplicationTesterTest.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\Tester;
13
14 use Symfony\Component\Console\Application;
15 use Symfony\Component\Console\Output\Output;
16 use Symfony\Component\Console\Tester\ApplicationTester;
17
18 class ApplicationTesterTest extends \PHPUnit_Framework_TestCase
19 {
20     protected $application;
21     protected $tester;
22
23     protected function setUp()
24     {
25         $this->application = new Application();
26         $this->application->setAutoExit(false);
27         $this->application->register('foo')
28             ->addArgument('foo')
29             ->setCode(function ($input, $output) { $output->writeln('foo'); })
30         ;
31
32         $this->tester = new ApplicationTester($this->application);
33         $this->tester->run(array('command' => 'foo', 'foo' => 'bar'), array('interactive' => false, 'decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE));
34     }
35
36     protected function tearDown()
37     {
38         $this->application = null;
39         $this->tester = null;
40     }
41
42     public function testRun()
43     {
44         $this->assertFalse($this->tester->getInput()->isInteractive(), '->execute() takes an interactive option');
45         $this->assertFalse($this->tester->getOutput()->isDecorated(), '->execute() takes a decorated option');
46         $this->assertEquals(Output::VERBOSITY_VERBOSE, $this->tester->getOutput()->getVerbosity(), '->execute() takes a verbosity option');
47     }
48
49     public function testGetInput()
50     {
51         $this->assertEquals('bar', $this->tester->getInput()->getArgument('foo'), '->getInput() returns the current input instance');
52     }
53
54     public function testGetOutput()
55     {
56         rewind($this->tester->getOutput()->getStream());
57         $this->assertEquals('foo'.PHP_EOL, stream_get_contents($this->tester->getOutput()->getStream()), '->getOutput() returns the current output instance');
58     }
59
60     public function testGetDisplay()
61     {
62         $this->assertEquals('foo'.PHP_EOL, $this->tester->getDisplay(), '->getDisplay() returns the display of the last execution');
63     }
64 }