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 const PHP_OS_FAMILY;
  12. use PHPUnit\Framework\TestCase;
  13. /**
  14. * @covers \SebastianBergmann\Environment\OperatingSystem
  15. */
  16. final class OperatingSystemTest extends TestCase
  17. {
  18. /**
  19. * @var \SebastianBergmann\Environment\OperatingSystem
  20. */
  21. private $os;
  22. protected function setUp(): void
  23. {
  24. $this->os = new OperatingSystem;
  25. }
  26. /**
  27. * @requires OS Linux
  28. */
  29. public function testFamilyCanBeRetrieved(): void
  30. {
  31. $this->assertEquals('Linux', $this->os->getFamily());
  32. }
  33. /**
  34. * @requires OS Darwin
  35. */
  36. public function testFamilyReturnsDarwinWhenRunningOnDarwin(): void
  37. {
  38. $this->assertEquals('Darwin', $this->os->getFamily());
  39. }
  40. /**
  41. * @requires OS Windows
  42. */
  43. public function testGetFamilyReturnsWindowsWhenRunningOnWindows(): void
  44. {
  45. $this->assertSame('Windows', $this->os->getFamily());
  46. }
  47. /**
  48. * @requires PHP 7.2.0
  49. */
  50. public function testGetFamilyReturnsPhpOsFamilyWhenRunningOnPhp72AndGreater(): void
  51. {
  52. $this->assertSame(PHP_OS_FAMILY, $this->os->getFamily());
  53. }
  54. }