Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / symfony / console / Tests / Style / SymfonyStyleTest.php
index ef6b72a07cc383f11a9cd11c00ed8ff2fadcdced..865bb33f79323289ad2f621e525c8b8597c5c9ef 100644 (file)
@@ -14,6 +14,11 @@ namespace Symfony\Component\Console\Tests\Style;
 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
 {
@@ -71,4 +76,41 @@ 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());
+    }
 }