Symfony\Component\Console\Application::setTerminalDimensions PHP Method

setTerminalDimensions() public method

Can be useful to force terminal dimensions for functional tests.
Deprecation: since version 3.2, to be removed in 4.0. Set the COLUMNS and LINES env vars instead.
public setTerminalDimensions ( integer $width, integer $height ) : Application
$width integer The width
$height integer The height
return Application The current application
    public function setTerminalDimensions($width, $height)
    {
        @trigger_error(sprintf('%s is deprecated as of 3.2 and will be removed in 4.0. Set the COLUMNS and LINES env vars instead.', __METHOD__), E_USER_DEPRECATED);
        putenv('COLUMNS=' . $width);
        putenv('LINES=' . $height);
        return $this;
    }

Usage Example

Example #1
0
 public function testTerminalDimensions()
 {
     $application = new Application();
     $originalDimensions = $application->getTerminalDimensions();
     $this->assertCount(2, $originalDimensions);
     $width = 80;
     if ($originalDimensions[0] == $width) {
         $width = 100;
     }
     $application->setTerminalDimensions($width, 80);
     $this->assertSame(array($width, 80), $application->getTerminalDimensions());
 }