HelpCommandTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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\Command;
  13. use PhpCsFixer\Console\Command\HelpCommand;
  14. use PhpCsFixer\FixerConfiguration\FixerOption;
  15. use PhpCsFixer\FixerConfiguration\FixerOptionInterface;
  16. use PhpCsFixer\Tests\TestCase;
  17. /**
  18. * @internal
  19. *
  20. * @covers \PhpCsFixer\Console\Command\HelpCommand
  21. */
  22. final class HelpCommandTest extends TestCase
  23. {
  24. /**
  25. * @param null|mixed $expected
  26. *
  27. * @dataProvider provideGetDisplayableAllowedValuesCases
  28. */
  29. public function testGetDisplayableAllowedValues($expected, FixerOptionInterface $input): void
  30. {
  31. self::assertSame($expected, HelpCommand::getDisplayableAllowedValues($input));
  32. }
  33. public static function provideGetDisplayableAllowedValuesCases(): iterable
  34. {
  35. yield [null, new FixerOption('foo', 'bar', false, null, ['int'], [])];
  36. yield [['A', 'B', 'x', 'z'], new FixerOption('foo', 'bar', false, null, ['string'], ['z', 'x', 'B', 'A'])];
  37. yield [[0, 3, 9], new FixerOption('foo', 'bar', false, null, ['int'], [0, 3, 9, static fn () => true])];
  38. yield [null, new FixerOption('foo', 'bar')];
  39. }
  40. }