UnixSystemUtilTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. declare(strict_types=1);
  3. namespace SPC\Tests\builder\unix;
  4. use PHPUnit\Framework\TestCase;
  5. use SPC\builder\freebsd\SystemUtil as FreebsdSystemUtil;
  6. use SPC\builder\linux\SystemUtil as LinuxSystemUtil;
  7. use SPC\builder\macos\SystemUtil as MacosSystemUtil;
  8. use SPC\exception\FileSystemException;
  9. /**
  10. * @internal
  11. */
  12. class UnixSystemUtilTest extends TestCase
  13. {
  14. private FreebsdSystemUtil|LinuxSystemUtil|MacosSystemUtil $util;
  15. public function setUp(): void
  16. {
  17. $util_class = match (PHP_OS_FAMILY) {
  18. 'Linux' => 'SPC\builder\linux\SystemUtil',
  19. 'Darwin' => 'SPC\builder\macos\SystemUtil',
  20. 'FreeBSD' => 'SPC\builder\freebsd\SystemUtil',
  21. default => null,
  22. };
  23. if ($util_class === null) {
  24. self::markTestIncomplete('This test is only for Unix');
  25. }
  26. $this->util = new $util_class();
  27. }
  28. /**
  29. * @throws FileSystemException
  30. */
  31. public function testMakeCmakeToolchainFile()
  32. {
  33. $str = $this->util->makeCmakeToolchainFile(PHP_OS_FAMILY, 'x86_64', '');
  34. $this->assertIsString($str);
  35. }
  36. public function testFindCommand()
  37. {
  38. $this->assertIsString($this->util->findCommand('bash'));
  39. }
  40. public function testMakeEnvVarString()
  41. {
  42. $this->assertEquals("PATH='/usr/bin' PKG_CONFIG='/usr/bin/pkg-config'", $this->util->makeEnvVarString(['PATH' => '/usr/bin', 'PKG_CONFIG' => '/usr/bin/pkg-config']));
  43. }
  44. }