4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Console\Tests\Style;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Console\Command\Command;
16 use Symfony\Component\Console\Tester\CommandTester;
18 class SymfonyStyleTest extends TestCase
22 /** @var CommandTester */
25 protected function setUp()
27 putenv('COLUMNS=121');
28 $this->command = new Command('sfstyle');
29 $this->tester = new CommandTester($this->command);
32 protected function tearDown()
35 $this->command = null;
40 * @dataProvider inputCommandToOutputFilesProvider
42 public function testOutputs($inputCommandFilepath, $outputFilepath)
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));
51 * @dataProvider inputInteractiveCommandToOutputFilesProvider
53 public function testInteractiveOutputs($inputCommandFilepath, $outputFilepath)
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));
61 public function inputInteractiveCommandToOutputFilesProvider()
63 $baseDir = __DIR__.'/../Fixtures/Style/SymfonyStyle';
65 return array_map(null, glob($baseDir.'/command/interactive_command_*.php'), glob($baseDir.'/output/interactive_output_*.txt'));
68 public function inputCommandToOutputFilesProvider()
70 $baseDir = __DIR__.'/../Fixtures/Style/SymfonyStyle';
72 return array_map(null, glob($baseDir.'/command/command_*.php'), glob($baseDir.'/output/output_*.txt'));