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:
parent
2e2cec29bd
commit
7e71b2bfbc
2 changed files with 36 additions and 18 deletions
|
@ -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());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue