ToolInfoTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of PHP CS Fixer.
  5. *
  6. * (c) Fabien Potencier <fabien@symfony.com>
  7. * Dariusz Rumiński <dariusz.ruminski@gmail.com>
  8. *
  9. * This source file is subject to the MIT license that is bundled
  10. * with this source code in the file LICENSE.
  11. */
  12. namespace PhpCsFixer\Tests;
  13. use PhpCsFixer\Console\Application;
  14. use PhpCsFixer\ToolInfo;
  15. /**
  16. * @internal
  17. *
  18. * @covers \PhpCsFixer\ToolInfo
  19. */
  20. final class ToolInfoTest extends TestCase
  21. {
  22. public function testGetVersion(): void
  23. {
  24. $toolInfo = new ToolInfo();
  25. self::assertStringStartsWith(Application::VERSION, $toolInfo->getVersion());
  26. }
  27. public function testIsInstallAsPhar(): void
  28. {
  29. $toolInfo = new ToolInfo();
  30. self::assertFalse($toolInfo->isInstalledAsPhar());
  31. }
  32. public function testIsInstalledByComposer(): void
  33. {
  34. $toolInfo = new ToolInfo();
  35. self::assertFalse($toolInfo->isInstalledByComposer());
  36. }
  37. public function testGetComposerVersionThrowsExceptionIfOutsideComposerScope(): void
  38. {
  39. $toolInfo = new ToolInfo();
  40. $this->expectException(\LogicException::class);
  41. $toolInfo->getComposerVersion();
  42. }
  43. public function testGetPharDownloadUri(): void
  44. {
  45. $toolInfo = new ToolInfo();
  46. self::assertSame(
  47. 'https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases/download/foo/php-cs-fixer.phar',
  48. $toolInfo->getPharDownloadUri('foo')
  49. );
  50. }
  51. }