1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 00:22:53 +00:00

Added support for expanding environment variables in paths, and tilde expansion on Windows.

This commit is contained in:
Niels Keurentjes 2016-04-12 23:07:58 +02:00
parent 2e2cec29bd
commit 7e71b2bfbc
2 changed files with 36 additions and 18 deletions

View file

@ -21,7 +21,18 @@ use Composer\Util\Platform;
*/
class PlatformTest extends \PHPUnit_Framework_TestCase
{
public function testWindows()
public function testExpandPath()
{
putenv('TESTENV=/home/test');
if (Platform::isWindows()) {
$this->assertEquals('/home/test/myPath', Platform::expandPath('%TESTENV%/myPath'));
} else {
$this->assertEquals('/home/test/myPath', Platform::expandPath('$TESTENV/myPath'));
}
$this->assertEquals((getenv('HOME') ?: getenv('USERPROFILE')) . DIRECTORY_SEPARATOR . 'test', Platform::expandPath('~/test'));
}
public function testIsWindows()
{
// Compare 2 common tests for Windows to the built-in Windows test
$this->assertEquals(('\\' === DIRECTORY_SEPARATOR), Platform::isWindows());