ProjectFixerConfigurationTest.php 1.6 KB

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