8000 merged branch Seldaek/termwidth (PR #3805) · symfony/symfony@38e17c2 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 38e17c2

Browse files
committed
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).
2 parents 1387415 + 7ce22f0 commit 38e17c2

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/Symfony/Component/Console/Application.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,11 @@ public function renderException($e, $output)
789789
}
790790
}
791791

792+
/**
793+
* Tries to figure out the terminal width in which this application runs
794+
*
795+
* @return int|null
796+
*/
792797
protected function getTerminalWidth()
793798
{
794799
if (defined('PHP_WINDOWS_VERSION_BUILD') && $ansicon = getenv('ANSICON')) {
@@ -800,6 +805,11 @@ protected function getTerminalWidth()
800805
}
801806
}
802807

808+
/**
809+
* Tries to figure out the terminal height in which this application runs
810+
*
811+
* @return int|null
812+
*/
803813
protected function getTerminalHeight()
804814
{
805815
if (defined('PHP_WINDOWS_VERSION_BUILD') && $ansicon = getenv('ANSICON')) {

tests/Symfony/Tests/Component/Console/ApplicationTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,11 @@ public function testFind()
201201

202202
public function testSetCatchExceptions()
203203
{
204-
$application = new Application();
204+
$application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));
205205
$application->setAutoExit(false);
206+
$application->expects($this->any())
207+
->method('getTerminalWidth')
208+
->will($this->returnValue(120));
206209
$tester = new ApplicationTester($application);
207210

208211
$application->setCatchExceptions(true);
@@ -237,8 +240,11 @@ public function testAsXml()
237240

238241
public function testRenderException()
239242
{
240-
$application = new Application();
243+
$application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));
241244
$application->setAutoExit(false);
245+
$application->expects($this->any())
246+
->method('getTerminalWidth')
247+
->will($this->returnValue(120));
242248
$tester = new ApplicationTester($application);
243249

244250
$tester->run(array('command' => 'foo'), array('decorated' => false));

0 commit comments

Comments
 (0)
0