TerminalTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Console\Tests;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\Console\Terminal;
  13. class TerminalTest extends TestCase
  14. {
  15. private $colSize;
  16. private $lineSize;
  17. protected function setUp()
  18. {
  19. $this->colSize = getenv('COLUMNS');
  20. $this->lineSize = getenv('LINES');
  21. }
  22. protected function tearDown()
  23. {
  24. putenv($this->colSize ? 'COLUMNS='.$this->colSize : 'COLUMNS');
  25. putenv($this->lineSize ? 'LINES' : 'LINES='.$this->lineSize);
  26. }
  27. public function test()
  28. {
  29. putenv('COLUMNS=100');
  30. putenv('LINES=50');
  31. $terminal = new Terminal();
  32. $this->assertSame(100, $terminal->getWidth());
  33. $this->assertSame(50, $terminal->getHeight());
  34. putenv('COLUMNS=120');
  35. putenv('LINES=60');
  36. $terminal = new Terminal();
  37. $this->assertSame(120, $terminal->getWidth());
  38. $this->assertSame(60, $terminal->getHeight());
  39. }
  40. public function test_zero_values()
  41. {
  42. putenv('COLUMNS=0');
  43. putenv('LINES=0');
  44. $terminal = new Terminal();
  45. $this->assertSame(0, $terminal->getWidth());
  46. $this->assertSame(0, $terminal->getHeight());
  47. }
  48. }