ComposerTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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\AutoReview;
  13. use PhpCsFixer\Console\Application;
  14. use PhpCsFixer\Tests\TestCase;
  15. /**
  16. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  17. *
  18. * @internal
  19. *
  20. * @coversNothing
  21. * @group auto-review
  22. * @group covers-nothing
  23. */
  24. final class ComposerTest extends TestCase
  25. {
  26. public function testBranchAlias(): void
  27. {
  28. $composerJson = json_decode(file_get_contents(__DIR__.'/../../composer.json'), true);
  29. if (!isset($composerJson['extra']['branch-alias'])) {
  30. $this->addToAssertionCount(1); // composer.json doesn't contain branch alias, all good!
  31. return;
  32. }
  33. static::assertSame(
  34. ['dev-master' => $this->convertAppVersionToAliasedVersion(Application::VERSION)],
  35. $composerJson['extra']['branch-alias']
  36. );
  37. }
  38. private function convertAppVersionToAliasedVersion(string $version): string
  39. {
  40. $parts = explode('.', $version, 3);
  41. return sprintf('%d.%d-dev', $parts[0], $parts[1]);
  42. }
  43. }