XdebugHandlerTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 static $envAllow;
  19. public function testRestartWhenLoaded()
  20. {
  21. $loaded = true;
  22. $xdebug = new XdebugHandlerMock($loaded);
  23. $xdebug->check();
  24. $this->assertTrue($xdebug->restarted || !defined('PHP_BINARY'));
  25. }
  26. public function testNoRestartWhenNotLoaded()
  27. {
  28. $loaded = false;
  29. $xdebug = new XdebugHandlerMock($loaded);
  30. $xdebug->check();
  31. $this->assertFalse($xdebug->restarted);
  32. }
  33. public function testNoRestartWhenLoadedAndAllowed()
  34. {
  35. $loaded = true;
  36. putenv(XdebugHandlerMock::ENV_ALLOW.'=1');
  37. $xdebug = new XdebugHandlerMock($loaded);
  38. $xdebug->check();
  39. $this->assertFalse($xdebug->restarted);
  40. }
  41. public static function setUpBeforeClass()
  42. {
  43. self::$envAllow = (bool) getenv(XdebugHandlerMock::ENV_ALLOW);
  44. }
  45. public static function tearDownAfterClass()
  46. {
  47. if (self::$envAllow) {
  48. putenv(XdebugHandlerMock::ENV_ALLOW.'=1');
  49. } else {
  50. putenv(XdebugHandlerMock::ENV_ALLOW.'=0');
  51. }
  52. }
  53. protected function setUp()
  54. {
  55. putenv(XdebugHandlerMock::ENV_ALLOW.'=0');
  56. }
  57. }