XdebugHandlerTest.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\Test;
  12. use Composer\Test\Mock\XdebugHandlerMock;
  13. /**
  14. * @author John Stevenson <john-stevenson@blueyonder.co.uk>
  15. */
  16. class XdebugHandlerTest extends \PHPUnit_Framework_TestCase
  17. {
  18. public function testRestartWhenLoaded()
  19. {
  20. $loaded = true;
  21. $xdebug = new XdebugHandlerMock($loaded);
  22. $xdebug->check();
  23. $this->assertTrue($xdebug->restarted || !defined('PHP_BINARY'));
  24. }
  25. public function testNoRestartWhenNotLoaded()
  26. {
  27. $loaded = false;
  28. $xdebug = new XdebugHandlerMock($loaded);
  29. $xdebug->check();
  30. $this->assertFalse($xdebug->restarted);
  31. }
  32. public function testNoRestartWhenLoadedAndAllowed()
  33. {
  34. $loaded = true;
  35. putenv(XdebugHandlerMock::ENV_ALLOW.'=1');
  36. $xdebug = new XdebugHandlerMock($loaded);
  37. $xdebug->check();
  38. $this->assertFalse($xdebug->restarted);
  39. // Clear env for subsequent tests
  40. putenv(XdebugHandlerMock::ENV_ALLOW.'=0');
  41. }
  42. public function testForceColorSupport()
  43. {
  44. $xdebug = new XdebugHandlerMock();
  45. $xdebug->output->setDecorated(true);
  46. $xdebug->check();
  47. $args = explode(' ', $xdebug->command);
  48. $this->assertTrue(in_array('--ansi', $args) || !defined('PHP_BINARY'));
  49. }
  50. public function testIgnoreColorSupportIfNoAnsi()
  51. {
  52. $xdebug = new XdebugHandlerMock();
  53. $xdebug->output->setDecorated(true);
  54. $_SERVER['argv'][] = '--no-ansi';
  55. $xdebug->check();
  56. $args = explode(' ', $xdebug->command);
  57. $this->assertTrue(!in_array('--ansi', $args) || !defined('PHP_BINARY'));
  58. }
  59. }