FixerDefinitionTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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\FixerDefinition;
  13. use PhpCsFixer\FixerDefinition\CodeSampleInterface;
  14. use PhpCsFixer\FixerDefinition\FixerDefinition;
  15. use PhpCsFixer\Tests\TestCase;
  16. /**
  17. * @internal
  18. *
  19. * @covers \PhpCsFixer\FixerDefinition\FixerDefinition
  20. */
  21. final class FixerDefinitionTest extends TestCase
  22. {
  23. public function testGetSummary(): void
  24. {
  25. $definition = new FixerDefinition('Foo', [], 'Bar');
  26. self::assertSame('Foo', $definition->getSummary());
  27. }
  28. public function testGetCodeSamples(): void
  29. {
  30. $samples = [
  31. $this->prophesize(CodeSampleInterface::class)->reveal(),
  32. $this->prophesize(CodeSampleInterface::class)->reveal(),
  33. ];
  34. $definition = new FixerDefinition('', $samples, '');
  35. self::assertSame($samples, $definition->getCodeSamples());
  36. }
  37. public function testGetDescription(): void
  38. {
  39. $definition = new FixerDefinition('', [], 'Foo');
  40. self::assertSame('Foo', $definition->getDescription());
  41. }
  42. public function testGetRiskyDescription(): void
  43. {
  44. $definition = new FixerDefinition('', [], 'Foo');
  45. self::assertNull($definition->getRiskyDescription());
  46. $definition = new FixerDefinition('', [], 'Foo', 'Bar');
  47. self::assertSame('Bar', $definition->getRiskyDescription());
  48. }
  49. }