use PHP_WINDOWS_VERSION_BUILD to detect Windows
This commit unifies the detection of Windows builds across the Symfony codebase.
This commit is contained in:
parent
5b16d8eab5
commit
559273ec1c
@ -289,7 +289,7 @@ class QuestionHelper extends Helper
|
|||||||
*/
|
*/
|
||||||
private function getHiddenResponse(OutputInterface $output, $inputStream)
|
private function getHiddenResponse(OutputInterface $output, $inputStream)
|
||||||
{
|
{
|
||||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||||
$exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
|
$exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
|
||||||
|
|
||||||
// handle code running from a phar
|
// handle code running from a phar
|
||||||
|
@ -130,7 +130,7 @@ class QuestionHelperTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testAskHiddenResponse()
|
public function testAskHiddenResponse()
|
||||||
{
|
{
|
||||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||||
$this->markTestSkipped('This test is not supported on Windows');
|
$this->markTestSkipped('This test is not supported on Windows');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public static function setUpBeforeClass()
|
public static function setUpBeforeClass()
|
||||||
{
|
{
|
||||||
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
|
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||||
static::$symlinkOnWindows = true;
|
static::$symlinkOnWindows = true;
|
||||||
$originDir = tempnam(sys_get_temp_dir(), 'sl');
|
$originDir = tempnam(sys_get_temp_dir(), 'sl');
|
||||||
$targetDir = tempnam(sys_get_temp_dir(), 'sl');
|
$targetDir = tempnam(sys_get_temp_dir(), 'sl');
|
||||||
@ -106,21 +106,21 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
|
|||||||
$this->markTestSkipped('symlink is not supported');
|
$this->markTestSkipped('symlink is not supported');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined('PHP_WINDOWS_VERSION_MAJOR') && false === static::$symlinkOnWindows) {
|
if ('\\' === DIRECTORY_SEPARATOR && false === static::$symlinkOnWindows) {
|
||||||
$this->markTestSkipped('symlink requires "Create symbolic links" privilege on windows');
|
$this->markTestSkipped('symlink requires "Create symbolic links" privilege on windows');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function markAsSkippedIfChmodIsMissing()
|
protected function markAsSkippedIfChmodIsMissing()
|
||||||
{
|
{
|
||||||
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
|
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||||
$this->markTestSkipped('chmod is not supported on windows');
|
$this->markTestSkipped('chmod is not supported on windows');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function markAsSkippedIfPosixIsMissing()
|
protected function markAsSkippedIfPosixIsMissing()
|
||||||
{
|
{
|
||||||
if (defined('PHP_WINDOWS_VERSION_MAJOR') || !function_exists('posix_isatty')) {
|
if ('\\' === DIRECTORY_SEPARATOR || !function_exists('posix_isatty')) {
|
||||||
$this->markTestSkipped('Posix is not supported');
|
$this->markTestSkipped('Posix is not supported');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1229,7 +1229,7 @@ class Process
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||||
return $result = false;
|
return $result = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ class ProcessPipes
|
|||||||
public function getDescriptors()
|
public function getDescriptors()
|
||||||
{
|
{
|
||||||
if ($this->disableOutput) {
|
if ($this->disableOutput) {
|
||||||
$nullstream = fopen(defined('PHP_WINDOWS_VERSION_BUILD') ? 'NUL' : '/dev/null', 'c');
|
$nullstream = fopen('\\' === DIRECTORY_SEPARATOR ? 'NUL' : '/dev/null', 'c');
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
array('pipe', 'r'),
|
array('pipe', 'r'),
|
||||||
|
@ -122,14 +122,14 @@ class ProcessBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$pb->setPrefix(array('/usr/bin/php', 'composer.phar'));
|
$pb->setPrefix(array('/usr/bin/php', 'composer.phar'));
|
||||||
|
|
||||||
$proc = $pb->setArguments(array('-v'))->getProcess();
|
$proc = $pb->setArguments(array('-v'))->getProcess();
|
||||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||||
$this->assertEquals('"/usr/bin/php" "composer.phar" "-v"', $proc->getCommandLine());
|
$this->assertEquals('"/usr/bin/php" "composer.phar" "-v"', $proc->getCommandLine());
|
||||||
} else {
|
} else {
|
||||||
$this->assertEquals("'/usr/bin/php' 'composer.phar' '-v'", $proc->getCommandLine());
|
$this->assertEquals("'/usr/bin/php' 'composer.phar' '-v'", $proc->getCommandLine());
|
||||||
}
|
}
|
||||||
|
|
||||||
$proc = $pb->setArguments(array('-i'))->getProcess();
|
$proc = $pb->setArguments(array('-i'))->getProcess();
|
||||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||||
$this->assertEquals('"/usr/bin/php" "composer.phar" "-i"', $proc->getCommandLine());
|
$this->assertEquals('"/usr/bin/php" "composer.phar" "-i"', $proc->getCommandLine());
|
||||||
} else {
|
} else {
|
||||||
$this->assertEquals("'/usr/bin/php' 'composer.phar' '-i'", $proc->getCommandLine());
|
$this->assertEquals("'/usr/bin/php' 'composer.phar' '-i'", $proc->getCommandLine());
|
||||||
|
Reference in New Issue
Block a user