-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
HelpCommandTest.php
84 lines (63 loc) · 2.13 KB
/
HelpCommandTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
declare(strict_types=1);
/*
* This file is part of PHP CS Fixer.
*
* (c) Fabien Potencier <fabien@symfony.com>
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace PhpCsFixer\Tests\Console\Command;
use PhpCsFixer\Console\Command\HelpCommand;
use PhpCsFixer\FixerConfiguration\FixerOption;
use PhpCsFixer\FixerConfiguration\FixerOptionInterface;
use PhpCsFixer\Tests\TestCase;
/**
* @internal
*
* @covers \PhpCsFixer\Console\Command\HelpCommand
*/
final class HelpCommandTest extends TestCase
{
/**
* @param mixed $input
*
* @dataProvider provideToStringCases
*/
public function testToString(string $expected, $input): void
{
static::assertSame($expected, HelpCommand::toString($input));
}
public static function provideToStringCases(): iterable
{
yield ["['a' => 3, 'b' => 'c']", ['a' => 3, 'b' => 'c']];
yield ['[[1], [2]]', [[1], [2]]];
yield ['[0 => [1], \'a\' => [2]]', [[1], 'a' => [2]]];
yield ['[1, 2, \'foo\', null]', [1, 2, 'foo', null]];
yield ['[1, 2]', [1, 2]];
yield ['[]', []];
yield ['1.5', 1.5];
yield ['false', false];
yield ['true', true];
yield ['1', 1];
yield ["'foo'", 'foo'];
}
/**
* @param null|mixed $expected
*
* @dataProvider provideGetDisplayableAllowedValuesCases
*/
public function testGetDisplayableAllowedValues($expected, FixerOptionInterface $input): void
{
static::assertSame($expected, HelpCommand::getDisplayableAllowedValues($input));
}
public static function provideGetDisplayableAllowedValuesCases(): iterable
{
yield [null, new FixerOption('foo', 'bar', false, null, ['int'], [])];
yield [['A', 'B', 'x', 'z'], new FixerOption('foo', 'bar', false, null, ['string'], ['z', 'x', 'B', 'A'])];
yield [[0, 3, 9], new FixerOption('foo', 'bar', false, null, ['int'], [0, 3, 9, static fn () => true])];
yield [null, new FixerOption('foo', 'bar')];
}
}