ProjectFixerConfigurationTest.php 1.6 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\AutoReview;
  13. use PhpCsFixer\Config;
  14. use PhpCsFixer\Console\ConfigurationResolver;
  15. use PhpCsFixer\Fixer\InternalFixerInterface;
  16. use PhpCsFixer\Tests\TestCase;
  17. use PhpCsFixer\ToolInfo;
  18. /**
  19. * @internal
  20. *
  21. * @coversNothing
  22. *
  23. * @group auto-review
  24. * @group covers-nothing
  25. */
  26. final class ProjectFixerConfigurationTest extends TestCase
  27. {
  28. public function testCreate(): void
  29. {
  30. $config = $this->loadConfig();
  31. self::assertContainsOnlyInstancesOf(InternalFixerInterface::class, $config->getCustomFixers());
  32. self::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(): void
  43. {
  44. $rules = $rulesSorted = array_keys($this->loadConfig()->getRules());
  45. sort($rulesSorted);
  46. self::assertSame($rulesSorted, $rules, 'Please sort the "rules" in `.php-cs-fixer.dist.php` of this project.');
  47. }
  48. private function loadConfig(): Config
  49. {
  50. return require __DIR__.'/../../.php-cs-fixer.dist.php';
  51. }
  52. }