use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;
+use Symfony\Component\Console\Formatter\OutputFormatter;
+use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Output\ConsoleOutputInterface;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
class SymfonyStyleTest extends TestCase
{
return array_map(null, glob($baseDir.'/command/command_*.php'), glob($baseDir.'/output/output_*.txt'));
}
+
+ public function testGetErrorStyle()
+ {
+ $input = $this->getMockBuilder(InputInterface::class)->getMock();
+
+ $errorOutput = $this->getMockBuilder(OutputInterface::class)->getMock();
+ $errorOutput
+ ->method('getFormatter')
+ ->willReturn(new OutputFormatter());
+ $errorOutput
+ ->expects($this->once())
+ ->method('write');
+
+ $output = $this->getMockBuilder(ConsoleOutputInterface::class)->getMock();
+ $output
+ ->method('getFormatter')
+ ->willReturn(new OutputFormatter());
+ $output
+ ->expects($this->once())
+ ->method('getErrorOutput')
+ ->willReturn($errorOutput);
+
+ $io = new SymfonyStyle($input, $output);
+ $io->getErrorStyle()->write('');
+ }
+
+ public function testGetErrorStyleUsesTheCurrentOutputIfNoErrorOutputIsAvailable()
+ {
+ $output = $this->getMockBuilder(OutputInterface::class)->getMock();
+ $output
+ ->method('getFormatter')
+ ->willReturn(new OutputFormatter());
+
+ $style = new SymfonyStyle($this->getMockBuilder(InputInterface::class)->getMock(), $output);
+
+ $this->assertInstanceOf(SymfonyStyle::class, $style->getErrorStyle());
+ }
}