JsonReporterTest.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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\Console\Report\ListSetsReport;
  13. use PhpCsFixer\Console\Report\ListSetsReport\JsonReporter;
  14. use PhpCsFixer\Console\Report\ListSetsReport\ReporterInterface;
  15. use PhpCsFixer\Tests\Test\Assert\AssertJsonSchemaTrait;
  16. /**
  17. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  18. *
  19. * @internal
  20. *
  21. * @covers \PhpCsFixer\Console\Report\ListSetsReport\JsonReporter
  22. */
  23. final class JsonReporterTest extends AbstractReporterTestCase
  24. {
  25. use AssertJsonSchemaTrait;
  26. protected function createReporter(): ReporterInterface
  27. {
  28. return new JsonReporter();
  29. }
  30. protected function getFormat(): string
  31. {
  32. return 'json';
  33. }
  34. protected function assertFormat(string $expected, string $input): void
  35. {
  36. self::assertJsonSchema(__DIR__.'/../../../../doc/schemas/list-sets/schema.json', $input);
  37. self::assertJsonStringEqualsJsonString($expected, $input);
  38. }
  39. protected static function createSimpleReport(): string
  40. {
  41. return '{
  42. "sets": {
  43. "@PhpCsFixer": {
  44. "description": "Rule set as used by the PHP-CS-Fixer development team, highly opinionated.",
  45. "isRisky": false,
  46. "name": "@PhpCsFixer"
  47. },
  48. "@Symfony:risky": {
  49. "description": "Rules that follow the official `Symfony Coding Standards <https:\/\/symfony.com\/doc\/current\/contributing\/code\/standards.html>`_.",
  50. "isRisky": true,
  51. "name": "@Symfony:risky"
  52. }
  53. }
  54. }';
  55. }
  56. }