Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Sets the value of an environment variable
<?php putenv(string $assignment): bool
<?php public static function putEnv($name, $value)
{
$value = (string) $value;
putenv($name . '=' . $value);
$_SERVER[$name] = $_ENV[$name] = $value;
}
<?php public static function clearEnv($name)
{
putenv($name);
unset($_SERVER[$name], $_ENV[$name]);
}
<?php {
parent::tearDown();
putenv('COMPOSER_NO_INTERACTION');
}
public function testDevWarning()
<?php $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
$outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
putenv('COMPOSER_NO_INTERACTION=1');
$inputMock->expects($this->any())
->method('hasParameterOption')
<?php $inputMock = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock();
$outputMock = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
putenv('COMPOSER_NO_INTERACTION=1');
$inputMock->expects($this->any())
->method('hasParameterOption')
<?php public function testProcessTimeout()
{
putenv('COMPOSER_PROCESS_TIMEOUT=0');
$config = new Config(true);
$this->assertEquals(0, $config->get('process-timeout'));
putenv('COMPOSER_PROCESS_TIMEOUT');
<?php putenv('COMPOSER_PROCESS_TIMEOUT=0');
$config = new Config(true);
$this->assertEquals(0, $config->get('process-timeout'));
putenv('COMPOSER_PROCESS_TIMEOUT');
}
public function testHtaccessProtect()
<?php public function testHtaccessProtect()
{
putenv('COMPOSER_HTACCESS_PROTECT=0');
$config = new Config(true);
$this->assertEquals(0, $config->get('htaccess-protect'));
putenv('COMPOSER_HTACCESS_PROTECT');
<?php putenv('COMPOSER_HTACCESS_PROTECT=0');
$config = new Config(true);
$this->assertEquals(0, $config->get('htaccess-protect'));
putenv('COMPOSER_HTACCESS_PROTECT');
}
public function testGetSourceOfValue()
<?php public function testGetSourceOfValueEnvVariables()
{
putenv('COMPOSER_HTACCESS_PROTECT=0');
$config = new Config;
$this->assertEquals('COMPOSER_HTACCESS_PROTECT', $config->getSourceOfValue('htaccess-protect'));
putenv('COMPOSER_HTACCESS_PROTECT');
<?php putenv('COMPOSER_HTACCESS_PROTECT=0');
$config = new Config;
$this->assertEquals('COMPOSER_HTACCESS_PROTECT', $config->getSourceOfValue('htaccess-protect'));
putenv('COMPOSER_HTACCESS_PROTECT');
}
}
<?php {
if (false !== self::$envOriginal) {
putenv('COMPOSER_ORIGINAL_INIS='.self::$envOriginal);
} else {
putenv('COMPOSER_ORIGINAL_INIS');
}
<?php if (false !== self::$envOriginal) {
putenv('COMPOSER_ORIGINAL_INIS='.self::$envOriginal);
} else {
putenv('COMPOSER_ORIGINAL_INIS');
}
}
<?php protected function setEnv(array $paths)
{
putenv('COMPOSER_ORIGINAL_INIS='.implode(PATH_SEPARATOR, $paths));
}
}
<?php {
public function testExpandPath()
{
putenv('TESTENV=/home/test');
$this->assertEquals('/home/test/myPath', Platform::expandPath('%TESTENV%/myPath'));
$this->assertEquals('/home/test/myPath', Platform::expandPath('$TESTENV/myPath'));
$this->assertEquals((getenv('HOME') ?: getenv('USERPROFILE')) . '/test', Platform::expandPath('~/test'));