File tree
Expand file treeCollapse file tree1 file changed
+26
-0
lines changed Expand file treeCollapse file tree1 file changed
+26
-0
lines changed Original file line number | Diff line number | Diff line change |
---|
@@ -574,6 +574,32 @@ 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 | +When testing your commands, it could be useful to understand how your command |
| 578 | +reacts on different settings like the width and the height of the terminal, or |
| 579 | +even the color mode being used. You have access to such information thanks to the |
| 580 | +:class:`Symfony\\Component\\Console\\Terminal` class: |
| 581 | + |
| 582 | +use Symfony\Component\Console\Terminal; |
| 583 | + |
| 584 | +$terminal = new Terminal(); |
| 585 | + |
| 586 | +// gets the number of lines available |
| 587 | +$height = $terminal->getHeight(); |
| 588 | + |
| 589 | +// gets the number of columns available |
| 590 | +$width = $terminal->getWidth(); |
| 591 | + |
| 592 | +// gets the color mode |
| 593 | +$colorMode = $terminal->getColorMode(); |
| 594 | + |
| 595 | +// changes the color mode |
| 596 | +$colorMode = $terminal->setColorMode(AnsiColorMode::Ansi24); |
| 597 | + |
| 598 | +.. versionadded:: 6.2 |
| 599 | + |
| 600 | +The support for setting and getting the current color mode was introduced |
| 601 | +in Symfony 6.2. |
| 602 | + |
577 | 603 | Logging Command Errors
|
578 | 604 | ----------------------
|
579 | 605 |
|
|
You can’t perform that action at this time.
0 commit comments