2016-08-05 10:43:56 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of Composer.
|
|
|
|
*
|
|
|
|
* (c) Nils Adermann <naderman@naderman.de>
|
|
|
|
* Jordi Boggiano <j.boggiano@seld.be>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Composer\Test;
|
|
|
|
|
2016-09-06 13:48:37 +00:00
|
|
|
use Composer\Test\Mock\XdebugHandlerMock;
|
2016-08-05 10:43:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author John Stevenson <john-stevenson@blueyonder.co.uk>
|
|
|
|
*/
|
|
|
|
class XdebugHandlerTest extends \PHPUnit_Framework_TestCase
|
|
|
|
{
|
2016-09-06 19:17:18 +00:00
|
|
|
public static $envAllow;
|
|
|
|
|
2016-08-05 10:43:56 +00:00
|
|
|
public function testRestartWhenLoaded()
|
|
|
|
{
|
|
|
|
$loaded = true;
|
|
|
|
|
2016-09-06 13:48:37 +00:00
|
|
|
$xdebug = new XdebugHandlerMock($loaded);
|
2016-08-05 10:43:56 +00:00
|
|
|
$xdebug->check();
|
|
|
|
$this->assertTrue($xdebug->restarted || !defined('PHP_BINARY'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testNoRestartWhenNotLoaded()
|
|
|
|
{
|
|
|
|
$loaded = false;
|
|
|
|
|
2016-09-06 13:48:37 +00:00
|
|
|
$xdebug = new XdebugHandlerMock($loaded);
|
2016-08-05 10:43:56 +00:00
|
|
|
$xdebug->check();
|
|
|
|
$this->assertFalse($xdebug->restarted);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testNoRestartWhenLoadedAndAllowed()
|
|
|
|
{
|
|
|
|
$loaded = true;
|
2016-09-06 13:48:37 +00:00
|
|
|
putenv(XdebugHandlerMock::ENV_ALLOW.'=1');
|
2016-08-05 10:43:56 +00:00
|
|
|
|
2016-09-06 13:48:37 +00:00
|
|
|
$xdebug = new XdebugHandlerMock($loaded);
|
2016-08-05 10:43:56 +00:00
|
|
|
$xdebug->check();
|
|
|
|
$this->assertFalse($xdebug->restarted);
|
|
|
|
}
|
2016-09-06 13:48:37 +00:00
|
|
|
|
2016-09-06 19:17:18 +00:00
|
|
|
public static function setUpBeforeClass()
|
2016-09-06 13:48:37 +00:00
|
|
|
{
|
2016-09-06 19:17:18 +00:00
|
|
|
self::$envAllow = (bool) getenv(XdebugHandlerMock::ENV_ALLOW);
|
2016-09-06 13:48:37 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 19:17:18 +00:00
|
|
|
public static function tearDownAfterClass()
|
2016-09-06 13:48:37 +00:00
|
|
|
{
|
2016-09-06 19:17:18 +00:00
|
|
|
if (self::$envAllow) {
|
|
|
|
putenv(XdebugHandlerMock::ENV_ALLOW.'=1');
|
|
|
|
} else {
|
|
|
|
putenv(XdebugHandlerMock::ENV_ALLOW.'=0');
|
|
|
|
}
|
|
|
|
}
|
2016-09-06 13:48:37 +00:00
|
|
|
|
2016-09-06 19:17:18 +00:00
|
|
|
protected function setUp()
|
|
|
|
{
|
|
|
|
putenv(XdebugHandlerMock::ENV_ALLOW.'=0');
|
2016-09-06 13:48:37 +00:00
|
|
|
}
|
2016-08-05 10:43:56 +00:00
|
|
|
}
|