File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -574,6 +574,38 @@ call ``setAutoExit(false)`` on it to get the command result in ``CommandTester``
574
574
:class: `Symfony\\ Component\\ Console\\ Application `
575
575
and extend the normal ``\PHPUnit\Framework\TestCase ``.
576
576
577
+
578
+ When testing your commands, it could be useful to understand how your command
579
+ reacts on different settings like the width and the height of the terminal, or
580
+ even the color mode being used.
581
+ Thanks to the :class: `Symfony\\ Component\\ Console\\ Terminal ` class, you can
582
+ have access to such information::
583
+
584
+ use Symfony\Component\Console\Terminal;
585
+ use Symfony\Component\Console\Output\AnsiColorMode;
586
+
587
+ $terminal = new Terminal();
588
+
589
+ // access to number of lines available
590
+ $height = $terminal->getHeight();
591
+
592
+ // access to number of columns available
593
+ $width = $terminal->getWidth();
594
+
595
+ // access to the color mode
596
+ $colorMode = $terminal->getColorMode();
597
+
598
+ // set the color mode to use
599
+ $colorMode = $terminal->setColorMode(AnsiColorMode::Ansi24);
600
+
601
+ By default, the ``Terminal `` class uses the values of the
602
+ ``LINES `` and ``COLUMNS `` system environment variables.
603
+
604
+ .. versionadded :: 6.2
605
+
606
+ The support for setting and getting the current color mode was introduced
607
+ in Symfony 6.2.
608
+
577
609
Logging Command Errors
578
610
----------------------
579
611
You can’t perform that action at this time.
0 commit comments