ComposerTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /*
  3. * This file is part of PHP CS Fixer.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. * Dariusz Rumiński <dariusz.ruminski@gmail.com>
  7. *
  8. * This source file is subject to the MIT license that is bundled
  9. * with this source code in the file LICENSE.
  10. */
  11. namespace PhpCsFixer\tests\AutoReview;
  12. use PhpCsFixer\Console\Application;
  13. use PhpCsFixer\Tests\TestCase;
  14. /**
  15. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  16. *
  17. * @internal
  18. *
  19. * @coversNothing
  20. * @group auto-review
  21. */
  22. final class ComposerTest extends TestCase
  23. {
  24. public function testBranchAlias()
  25. {
  26. $composerJson = json_decode(file_get_contents(__DIR__.'/../../composer.json'), true);
  27. if (!isset($composerJson['extra']['branch-alias'])) {
  28. $this->addToAssertionCount(1); // composer.json doesn't contain branch alias, all good!
  29. return;
  30. }
  31. $this->assertSame(
  32. ['dev-master' => $this->convertAppVersionToAliasedVersion(Application::VERSION)],
  33. $composerJson['extra']['branch-alias']
  34. );
  35. }
  36. /**
  37. * @param string $version
  38. *
  39. * @return strting
  40. */
  41. private function convertAppVersionToAliasedVersion($version)
  42. {
  43. $parts = explode('.', $version, 3);
  44. return sprintf('%d.%d-dev', $parts[0], $parts[1]);
  45. }
  46. }