You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.2 KiB
PHP

<?php declare(strict_types=1);
/*
* 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\Util;
use Composer\Util\Platform;
use Composer\Test\TestCase;
/**
* PlatformTest
*
* @author Niels Keurentjes <niels.keurentjes@omines.com>
*/
class PlatformTest extends TestCase
{
public function testExpandPath(): void
{
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'));
}
public function testIsWindows(): void
{
// Compare 2 common tests for Windows to the built-in Windows test
$this->assertEquals(('\\' === DIRECTORY_SEPARATOR), Platform::isWindows());
$this->assertEquals(defined('PHP_WINDOWS_VERSION_MAJOR'), Platform::isWindows());
}
}