merged branch Seldaek/termwidth (PR #3805)

Commits
-------

7ce22f0 [Console] Add docblocks
8a2b115 [Console] Mock terminal size to prevent formatting errors on small terminals

Discussion
----------

[Console] Fixes terminal width in tests

This fixes the [tests that broke on travis-ci](http://travis-ci.org/#!/symfony/symfony/jobs/1031109) (which seems to advertise a terminal width of ~34, not sure why).
This commit is contained in:
Fabien Potencier 2012-04-06 19:14:31 +02:00
commit 38e17c2e87
2 changed files with 18 additions and 2 deletions

View File

@ -789,6 +789,11 @@ class Application
}
}
/**
* Tries to figure out the terminal width in which this application runs
*
* @return int|null
*/
protected function getTerminalWidth()
{
if (defined('PHP_WINDOWS_VERSION_BUILD') && $ansicon = getenv('ANSICON')) {
@ -800,6 +805,11 @@ class Application
}
}
/**
* Tries to figure out the terminal height in which this application runs
*
* @return int|null
*/
protected function getTerminalHeight()
{
if (defined('PHP_WINDOWS_VERSION_BUILD') && $ansicon = getenv('ANSICON')) {

View File

@ -201,8 +201,11 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
public function testSetCatchExceptions()
{
$application = new Application();
$application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));
$application->setAutoExit(false);
$application->expects($this->any())
->method('getTerminalWidth')
->will($this->returnValue(120));
$tester = new ApplicationTester($application);
$application->setCatchExceptions(true);
@ -237,8 +240,11 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
public function testRenderException()
{
$application = new Application();
$application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));
$application->setAutoExit(false);
$application->expects($this->any())
->method('getTerminalWidth')
->will($this->returnValue(120));
$tester = new ApplicationTester($application);
$tester->run(array('command' => 'foo'), array('decorated' => false));