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