OperatingSystemTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php declare(strict_types=1);
  2. /*
  3. * This file is part of sebastian/environment.
  4. *
  5. * (c) Sebastian Bergmann <sebastian@phpunit.de>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace SebastianBergmann\Environment;
  11. use PHPUnit\Framework\TestCase;
  12. /**
  13. * @covers \SebastianBergmann\Environment\OperatingSystem
  14. */
  15. final class OperatingSystemTest extends TestCase
  16. {
  17. /**
  18. * @var \SebastianBergmann\Environment\OperatingSystem
  19. */
  20. private $os;
  21. protected function setUp(): void
  22. {
  23. $this->os = new OperatingSystem;
  24. }
  25. /**
  26. * @requires OS Linux
  27. */
  28. public function testFamilyCanBeRetrieved(): void
  29. {
  30. $this->assertEquals('Linux', $this->os->getFamily());
  31. }
  32. /**
  33. * @requires OS Darwin
  34. */
  35. public function testFamilyReturnsDarwinWhenRunningOnDarwin(): void
  36. {
  37. $this->assertEquals('Darwin', $this->os->getFamily());
  38. }
  39. /**
  40. * @requires OS Windows
  41. */
  42. public function testGetFamilyReturnsWindowsWhenRunningOnWindows(): void
  43. {
  44. $this->assertSame('Windows', $this->os->getFamily());
  45. }
  46. /**
  47. * @requires PHP 7.2.0
  48. */
  49. public function testGetFamilyReturnsPhpOsFamilyWhenRunningOnPhp72AndGreater(): void
  50. {
  51. $this->assertSame(\PHP_OS_FAMILY, $this->os->getFamily());
  52. }
  53. }