-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
NormalizeCommandProvider.php
109 lines (94 loc) 路 3.17 KB
/
NormalizeCommandProvider.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
declare(strict_types=1);
/**
* Copyright (c) 2018-2021 Andreas M枚ller
*
* For the full copyright and license information, please view
* the LICENSE.md file that was distributed with this source code.
*
* @see https://github.com/ergebnis/composer-normalize
*/
namespace Ergebnis\Composer\Normalize\Test\DataProvider\Command;
use Ergebnis\Composer\Normalize\Test;
use Ergebnis\Json\Normalizer\Format;
final class NormalizeCommandProvider
{
use Test\Util\Helper;
/**
* @return \Generator<string, array{0: Test\Util\CommandInvocation}>
*/
public function commandInvocation(): \Generator
{
foreach (self::commandInvocations() as $commandInvocation) {
yield $commandInvocation->style() => [
$commandInvocation,
];
}
}
/**
* @return \Generator<string, array{0: Test\Util\CommandInvocation, 1: string}>
*/
public function commandInvocationAndInvalidIndentSize(): \Generator
{
$faker = self::faker();
$numberGreaterThanZero = $faker->numberBetween(1);
/** @var array<string> $indentSizes */
$indentSizes = [
'string-arbitrary' => $faker->sentence,
'integer-zero-casted-to-string' => (string) 0,
'integer-less-than-zero-casted-to-string' => (string) (-1 * $numberGreaterThanZero),
];
foreach (self::commandInvocations() as $commandInvocation) {
foreach ($indentSizes as $indentSizeKey => $indentSize) {
$key = \sprintf(
'%s-indent-size-%s',
$commandInvocation->style(),
$indentSizeKey
);
yield $key => [
$commandInvocation,
$indentSize,
];
}
}
}
/**
* @return \Generator<string, array{0: Test\Util\CommandInvocation, 1: int, 2: string}>
*/
public function commandInvocationIndentSizeAndIndentStyle(): \Generator
{
/** @var array<int> $indentSizes */
$indentSizes = [
1,
self::faker()->numberBetween(2, 4),
];
foreach (self::commandInvocations() as $commandInvocation) {
foreach ($indentSizes as $indentSize) {
foreach (\array_keys(Format\Indent::CHARACTERS) as $indentStyle) {
$key = \sprintf(
'%s-indent-size-%d-indent-style-%s',
$commandInvocation->style(),
(string) $indentSize,
$indentStyle
);
yield $key => [
$commandInvocation,
$indentSize,
$indentStyle,
];
}
}
}
}
/**
* @return array<int, Test\Util\CommandInvocation>
*/
private static function commandInvocations(): array
{
return [
Test\Util\CommandInvocation::inCurrentWorkingDirectory(),
Test\Util\CommandInvocation::usingFileArgument(),
Test\Util\CommandInvocation::usingWorkingDirectoryOption(),
];
}
}