PlatformTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\Test\Util;
  12. use Composer\Util\Platform;
  13. use Composer\Test\TestCase;
  14. /**
  15. * PlatformTest
  16. *
  17. * @author Niels Keurentjes <niels.keurentjes@omines.com>
  18. */
  19. class PlatformTest extends TestCase
  20. {
  21. public function testExpandPath()
  22. {
  23. putenv('TESTENV=/home/test');
  24. $this->assertEquals('/home/test/myPath', Platform::expandPath('%TESTENV%/myPath'));
  25. $this->assertEquals('/home/test/myPath', Platform::expandPath('$TESTENV/myPath'));
  26. $this->assertEquals((getenv('HOME') ?: getenv('USERPROFILE')) . '/test', Platform::expandPath('~/test'));
  27. }
  28. public function testIsWindows()
  29. {
  30. // Compare 2 common tests for Windows to the built-in Windows test
  31. $this->assertEquals(('\\' === DIRECTORY_SEPARATOR), Platform::isWindows());
  32. $this->assertEquals(defined('PHP_WINDOWS_VERSION_MAJOR'), Platform::isWindows());
  33. }
  34. }