|
13 | 13 |
|
14 | 14 | use PHPUnit\Framework\TestCase;
|
15 | 15 | use Symfony\Component\Console\Command\Command;
|
| 16 | +use Symfony\Component\Console\Exception\RuntimeException; |
16 | 17 | use Symfony\Component\Console\Formatter\OutputFormatter;
|
17 | 18 | use Symfony\Component\Console\Input\ArrayInput;
|
18 | 19 | use Symfony\Component\Console\Input\InputInterface;
|
19 | 20 | use Symfony\Component\Console\Output\ConsoleOutputInterface;
|
| 21 | +use Symfony\Component\Console\Output\ConsoleSectionOutput; |
20 | 22 | use Symfony\Component\Console\Output\NullOutput;
|
21 | 23 | use Symfony\Component\Console\Output\OutputInterface;
|
22 | 24 | use Symfony\Component\Console\Style\SymfonyStyle;
|
@@ -106,6 +108,39 @@ public function testGetErrorStyle()
|
106 | 108 | $io->getErrorStyle()->write('');
|
107 | 109 | }
|
108 | 110 |
|
| 111 | + public function testCreateTableWithConsoleOutput() |
| 112 | + { |
| 113 | + $input = $this->createMock(InputInterface::class); |
| 114 | + $output = $this->createMock(ConsoleOutputInterface::class); |
| 115 | + $output |
| 116 | + ->method('getFormatter') |
| 117 | + ->willReturn(new OutputFormatter()); |
| 118 | + $output |
| 119 | + ->expects($this->once()) |
| 120 | + ->method('section') |
| 121 | + ->willReturn($this->createMock(ConsoleSectionOutput::class)); |
| 122 | + |
| 123 | + $style = new SymfonyStyle($input, $output); |
| 124 | + |
| 125 | + $style->createTable(); |
| 126 | + } |
| 127 | + |
| 128 | + public function testCreateTableWithoutConsoleOutput() |
| 129 | + { |
| 130 | + $input = $this->createMock(InputInterface::class); |
| 131 | + $output = $this->createMock(OutputInterface::class); |
| 132 | + $output |
| 133 | + ->method('getFormatter') |
| 134 | + ->willReturn(new OutputFormatter()); |
| 135 | + |
| 136 | + $style = new SymfonyStyle($input, $output); |
| 137 | + |
| 138 | + $this->expectException(RuntimeException::class); |
| 139 | + $this->expectDeprecationMessage('Output should be an instance of "Symfony\Component\Console\Output\ConsoleSectionOutput"'); |
| 140 | + |
| 141 | + $style->createTable()->appendRow(['row']); |
| 142 | + } |
| 143 | + |
109 | 144 | public function testGetErrorStyleUsesTheCurrentOutputIfNoErrorOutputIsAvailable()
|
110 | 145 | {
|
111 | 146 | $output = $this->createMock(OutputInterface::class);
|
|
0 commit comments