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. * @backupGlobals disabled
  17. * @runTestsInSeparateProcesses
  18. */
  19. class XdebugHandlerTest extends \PHPUnit_Framework_TestCase
  20. {
  21. public function testRestartWhenLoaded()
  22. {
  23. $loaded = true;
  24. $xdebug = new XdebugHandlerMock($loaded);
  25. $xdebug->check();
  26. $this->assertTrue($xdebug->restarted || !defined('PHP_BINARY'));
  27. }
  28. public function testNoRestartWhenNotLoaded()
  29. {
  30. $loaded = false;
  31. $xdebug = new XdebugHandlerMock($loaded);
  32. $xdebug->check();
  33. $this->assertFalse($xdebug->restarted);
  34. }
  35. public function testNoRestartWhenLoadedAndAllowed()
  36. {
  37. $loaded = true;
  38. putenv(XdebugHandlerMock::ENV_ALLOW.'=1');
  39. $xdebug = new XdebugHandlerMock($loaded);
  40. $xdebug->check();
  41. $this->assertFalse($xdebug->restarted);
  42. }
  43. public function testForceColorSupport()
  44. {
  45. $xdebug = new XdebugHandlerMock();
  46. $xdebug->output->setDecorated(true);
  47. $xdebug->check();
  48. $args = explode(' ', $xdebug->command);
  49. $this->assertTrue(in_array('--ansi', $args) || !defined('PHP_BINARY'));
  50. }
  51. public function testIgnoreColorSupportIfNoAnsi()
  52. {
  53. $xdebug = new XdebugHandlerMock();
  54. $xdebug->output->setDecorated(true);
  55. $_SERVER['argv'][] = '--no-ansi';
  56. $xdebug->check();
  57. $args = explode(' ', $xdebug->command);
  58. $this->assertTrue(!in_array('--ansi', $args) || !defined('PHP_BINARY'));
  59. }
  60. }