Skip to content

Commit

Permalink
merged 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Apr 8, 2012
2 parents c6096e3 + 38e17c2 commit 0e525fc
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/Symfony/Component/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,11 @@ public function renderException($e, $output)
}
}

/**
* 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')) {
Expand All @@ -838,6 +843,11 @@ protected function getTerminalWidth()
}
}

/**
* 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')) {
Expand Down
17 changes: 15 additions & 2 deletions src/Symfony/Component/Console/Tests/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,11 @@ public function testFindAlternativeNamespace()

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);
Expand Down Expand Up @@ -323,8 +326,11 @@ public function testAsXml()

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));
Expand All @@ -348,6 +354,13 @@ public function testRenderException()
->will($this->returnValue(32));
$tester = new ApplicationTester($application);

$application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));
$application->setAutoExit(false);
$application->expects($this->any())
->method('getTerminalWidth')
->will($this->returnValue(32));
$tester = new ApplicationTester($application);

$tester->run(array('command' => 'foo'), array('decorated' => false));
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception4.txt', $this->normalizeLineBreaks($tester->getDisplay()), '->renderException() wraps messages when they are bigger than the terminal');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Routing/RouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function getIterator()
public function add($name, Route $route)
{
if (!preg_match('/^[a-z0-9A-Z_.]+$/', $name)) {
throw new \InvalidArgumentException(sprintf('Name "%s" contains non valid characters for a route name.', $name));
throw new \InvalidArgumentException(sprintf('The provided route name "%s" contains non valid characters. A route name must only contain digits (0-9), letters (a-z and A-Z), underscores (_) and dots (.).', $name));
}

$parent = $this;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@



[InvalidArgumentException]
Command "foo" is not define
d.



0 comments on commit 0e525fc

Please sign in to comment.