Skip to content

Commit bcc295a

Browse files
[Console] Mention Terminal
1 parent e5295d3 commit bcc295a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

console.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,24 @@ call ``setAutoExit(false)`` on it to get the command result in ``CommandTester``
582582
:class:`Symfony\\Component\\Console\\Application`
583583
and extend the normal ``\PHPUnit\Framework\TestCase``.
584584

585+
When testing your commands, it could be useful to understand how your command
586+
reacts on different settings like the width and the height of the terminal.
587+
Thanks to the :class:`Symfony\\Component\\Console\\Terminal` class, you can
588+
have access to such information::
589+
590+
use Symfony\Component\Console\Terminal;
591+
592+
$terminal = new Terminal();
593+
594+
// access to number of lines available
595+
$height = $terminal->getHeight();
596+
597+
// access to number of columns available
598+
$width = $terminal->getWidth();
599+
600+
By default, the ``Terminal`` class uses the values of the
601+
``LINES`` and ``COLUMNS`` system environment variables.
602+
585603
Logging Command Errors
586604
----------------------
587605

0 commit comments

Comments
 (0)