2022-02-23 15:58:18 +00:00
|
|
|
<?php declare(strict_types=1);
|
2016-02-25 10:04:44 +00:00
|
|
|
|
|
|
|
/*
|
2016-02-03 21:25:43 +00:00
|
|
|
* 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;
|
2020-02-07 03:18:45 +00:00
|
|
|
use Composer\Test\TestCase;
|
2016-02-03 21:25:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* PlatformTest
|
|
|
|
*
|
|
|
|
* @author Niels Keurentjes <niels.keurentjes@omines.com>
|
|
|
|
*/
|
2017-11-04 14:52:13 +00:00
|
|
|
class PlatformTest extends TestCase
|
2016-02-03 21:25:43 +00:00
|
|
|
{
|
2022-02-18 09:38:54 +00:00
|
|
|
public function testExpandPath(): void
|
2016-04-12 21:07:58 +00:00
|
|
|
{
|
|
|
|
putenv('TESTENV=/home/test');
|
2024-05-29 21:12:06 +00:00
|
|
|
self::assertEquals('/home/test/myPath', Platform::expandPath('%TESTENV%/myPath'));
|
|
|
|
self::assertEquals('/home/test/myPath', Platform::expandPath('$TESTENV/myPath'));
|
|
|
|
self::assertEquals((getenv('HOME') ?: getenv('USERPROFILE')) . '/test', Platform::expandPath('~/test'));
|
2016-04-12 21:07:58 +00:00
|
|
|
}
|
2017-03-08 14:07:29 +00:00
|
|
|
|
2022-02-18 09:38:54 +00:00
|
|
|
public function testIsWindows(): void
|
2016-02-03 21:25:43 +00:00
|
|
|
{
|
|
|
|
// Compare 2 common tests for Windows to the built-in Windows test
|
2024-05-29 21:12:06 +00:00
|
|
|
self::assertEquals(('\\' === DIRECTORY_SEPARATOR), Platform::isWindows());
|
|
|
|
self::assertEquals(defined('PHP_WINDOWS_VERSION_MAJOR'), Platform::isWindows());
|
2016-02-03 21:25:43 +00:00
|
|
|
}
|
|
|
|
}
|