Security update for Core, with self-updated composer
[yaffs-website] / vendor / symfony / console / Tests / Style / SymfonyStyleTest.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\Style;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Console\Command\Command;
16 use Symfony\Component\Console\Tester\CommandTester;
17
18 class SymfonyStyleTest extends TestCase
19 {
20     /** @var Command */
21     protected $command;
22     /** @var CommandTester */
23     protected $tester;
24
25     protected function setUp()
26     {
27         putenv('COLUMNS=121');
28         $this->command = new Command('sfstyle');
29         $this->tester = new CommandTester($this->command);
30     }
31
32     protected function tearDown()
33     {
34         putenv('COLUMNS');
35         $this->command = null;
36         $this->tester = null;
37     }
38
39     /**
40      * @dataProvider inputCommandToOutputFilesProvider
41      */
42     public function testOutputs($inputCommandFilepath, $outputFilepath)
43     {
44         $code = require $inputCommandFilepath;
45         $this->command->setCode($code);
46         $this->tester->execute(array(), array('interactive' => false, 'decorated' => false));
47         $this->assertStringEqualsFile($outputFilepath, $this->tester->getDisplay(true));
48     }
49
50     /**
51      * @dataProvider inputInteractiveCommandToOutputFilesProvider
52      */
53     public function testInteractiveOutputs($inputCommandFilepath, $outputFilepath)
54     {
55         $code = require $inputCommandFilepath;
56         $this->command->setCode($code);
57         $this->tester->execute(array(), array('interactive' => true, 'decorated' => false));
58         $this->assertStringEqualsFile($outputFilepath, $this->tester->getDisplay(true));
59     }
60
61     public function inputInteractiveCommandToOutputFilesProvider()
62     {
63         $baseDir = __DIR__.'/../Fixtures/Style/SymfonyStyle';
64
65         return array_map(null, glob($baseDir.'/command/interactive_command_*.php'), glob($baseDir.'/output/interactive_output_*.txt'));
66     }
67
68     public function inputCommandToOutputFilesProvider()
69     {
70         $baseDir = __DIR__.'/../Fixtures/Style/SymfonyStyle';
71
72         return array_map(null, glob($baseDir.'/command/command_*.php'), glob($baseDir.'/output/output_*.txt'));
73     }
74 }