ProjectFixerConfigurationTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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\Config;
  14. use PhpCsFixer\Console\ConfigurationResolver;
  15. use PhpCsFixer\Tests\TestCase;
  16. use PhpCsFixer\ToolInfo;
  17. /**
  18. * @internal
  19. *
  20. * @coversNothing
  21. *
  22. * @group auto-review
  23. * @group covers-nothing
  24. */
  25. final class ProjectFixerConfigurationTest extends TestCase
  26. {
  27. public function testCreate(): void
  28. {
  29. $config = $this->loadConfig();
  30. self::assertEmpty($config->getCustomFixers());
  31. self::assertNotEmpty($config->getRules());
  32. // call so the fixers get configured to reveal issue (like deprecated configuration used etc.)
  33. $resolver = new ConfigurationResolver(
  34. $config,
  35. [],
  36. __DIR__,
  37. new ToolInfo()
  38. );
  39. $resolver->getFixers();
  40. }
  41. public function testRuleDefinedAlpha(): void
  42. {
  43. $rules = $rulesSorted = array_keys($this->loadConfig()->getRules());
  44. sort($rulesSorted);
  45. self::assertSame($rulesSorted, $rules, 'Please sort the "rules" in `.php-cs-fixer.dist.php` of this project.');
  46. }
  47. private function loadConfig(): Config
  48. {
  49. return require __DIR__.'/../../.php-cs-fixer.dist.php';
  50. }
  51. }