minor #31001 [Console] fix resetting the COLUMN environment variable (xabbuh)

This PR was merged into the 3.4 branch.

Discussion
----------

[Console] fix resetting the COLUMN environment variable

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Commits
-------

8fb2074972 fix resetting the COLUMN environment variable
This commit is contained in:
Fabien Potencier 2019-04-08 12:06:32 +02:00
commit d3eae71aa9
4 changed files with 16 additions and 16 deletions

View File

@ -48,6 +48,14 @@ class ApplicationTest extends TestCase
$this->colSize = getenv('COLUMNS');
}
protected function tearDown()
{
putenv($this->colSize ? 'COLUMNS='.$this->colSize : 'COLUMNS');
putenv('SHELL_VERBOSITY');
unset($_ENV['SHELL_VERBOSITY']);
unset($_SERVER['SHELL_VERBOSITY']);
}
public static function setUpBeforeClass()
{
self::$fixturesPath = realpath(__DIR__.'/Fixtures/');
@ -1698,14 +1706,6 @@ class ApplicationTest extends TestCase
$this->assertSame($e->getMessage(), 'Class \'UnknownClass\' not found');
}
}
protected function tearDown()
{
putenv($this->colSize ? 'COLUMNS' : 'COLUMNS='.$this->colSize);
putenv('SHELL_VERBOSITY');
unset($_ENV['SHELL_VERBOSITY']);
unset($_SERVER['SHELL_VERBOSITY']);
}
}
class CustomApplication extends Application

View File

@ -31,7 +31,7 @@ class ProgressBarTest extends TestCase
protected function tearDown()
{
putenv($this->colSize ? 'COLUMNS' : 'COLUMNS='.$this->colSize);
putenv($this->colSize ? 'COLUMNS='.$this->colSize : 'COLUMNS');
}
public function testMultipleStart()

View File

@ -38,7 +38,7 @@ class SymfonyStyleTest extends TestCase
protected function tearDown()
{
putenv($this->colSize ? 'COLUMNS' : 'COLUMNS='.$this->colSize);
putenv($this->colSize ? 'COLUMNS='.$this->colSize : 'COLUMNS');
$this->command = null;
$this->tester = null;
}

View File

@ -25,6 +25,12 @@ class TerminalTest extends TestCase
$this->lineSize = getenv('LINES');
}
protected function tearDown()
{
putenv($this->colSize ? 'COLUMNS='.$this->colSize : 'COLUMNS');
putenv($this->lineSize ? 'LINES' : 'LINES='.$this->lineSize);
}
public function test()
{
putenv('COLUMNS=100');
@ -40,12 +46,6 @@ class TerminalTest extends TestCase
$this->assertSame(60, $terminal->getHeight());
}
protected function tearDown()
{
putenv($this->colSize ? 'COLUMNS' : 'COLUMNS='.$this->colSize);
putenv($this->lineSize ? 'LINES' : 'LINES='.$this->lineSize);
}
public function test_zero_values()
{
putenv('COLUMNS=0');