-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathSettings.parseArguments.phpt
149 lines (124 loc) · 5.8 KB
/
Settings.parseArguments.phpt
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
/**
* @testCase
*/
require_once __DIR__ . '/../src/polyfill.php';
require __DIR__ . '/../vendor/autoload.php';
use PHP_Parallel_Lint\PhpParallelLint\Settings;
use Tester\Assert;
class SettingsParseArgumentsTest extends Tester\TestCase
{
public function testNoneArguments()
{
$commandLine = "./parallel-lint .";
$argv = explode(" ", $commandLine);
$settings = Settings::parseArguments($argv);
$expectedSettings = new Settings();
$expectedSettings->shortTag = false;
$expectedSettings->aspTags = false;
$expectedSettings->parallelJobs = 10;
$expectedSettings->extensions = array('php', 'phtml', 'php3', 'php4', 'php5', 'phpt');
$expectedSettings->paths = array('.');
$expectedSettings->excluded = array();
$expectedSettings->colors = Settings::AUTODETECT;
$expectedSettings->showProgress = true;
$expectedSettings->format = Settings::FORMAT_TEXT;
$expectedSettings->syntaxErrorCallbackFile = null;
Assert::equal($expectedSettings->shortTag, $settings->shortTag);
Assert::equal($expectedSettings->aspTags, $settings->aspTags);
Assert::equal($expectedSettings->parallelJobs, $settings->parallelJobs);
Assert::equal($expectedSettings->extensions, $settings->extensions);
Assert::equal($expectedSettings->paths, $settings->paths);
Assert::equal($expectedSettings->excluded, $settings->excluded);
Assert::equal($expectedSettings->colors, $settings->colors);
Assert::equal($expectedSettings->showProgress, $settings->showProgress);
Assert::equal($expectedSettings->format, $settings->format);
Assert::equal($expectedSettings->syntaxErrorCallbackFile, $settings->syntaxErrorCallbackFile);
}
public function testMoreArguments()
{
$commandLine = "./parallel-lint --exclude vendor --no-colors .";
$argv = explode(" ", $commandLine);
$settings = Settings::parseArguments($argv);
$expectedSettings = new Settings();
$expectedSettings->shortTag = false;
$expectedSettings->aspTags = false;
$expectedSettings->parallelJobs = 10;
$expectedSettings->extensions = array('php', 'phtml', 'php3', 'php4', 'php5', 'phpt');
$expectedSettings->paths = array('.');
$expectedSettings->excluded = array('vendor');
$expectedSettings->colors = Settings::DISABLED;
$expectedSettings->showProgress = true;
$expectedSettings->format = Settings::FORMAT_TEXT;
$expectedSettings->showDeprecated = false;
Assert::equal($expectedSettings->shortTag, $settings->shortTag);
Assert::equal($expectedSettings->aspTags, $settings->aspTags);
Assert::equal($expectedSettings->parallelJobs, $settings->parallelJobs);
Assert::equal($expectedSettings->extensions, $settings->extensions);
Assert::equal($expectedSettings->paths, $settings->paths);
Assert::equal($expectedSettings->excluded, $settings->excluded);
Assert::equal($expectedSettings->colors, $settings->colors);
Assert::equal($expectedSettings->showProgress, $settings->showProgress);
Assert::equal($expectedSettings->format, $settings->format);
Assert::equal($expectedSettings->showDeprecated, $settings->showDeprecated);
}
public function testColorsForced()
{
$commandLine = "./parallel-lint --exclude vendor --colors .";
$argv = explode(" ", $commandLine);
$settings = Settings::parseArguments($argv);
$expectedSettings = new Settings();
$expectedSettings->colors = Settings::FORCED;
Assert::equal($expectedSettings->colors, $settings->colors);
}
public function testNoProgress()
{
$commandLine = "./parallel-lint --exclude vendor --no-progress .";
$argv = explode(" ", $commandLine);
$settings = Settings::parseArguments($argv);
$expectedSettings = new Settings();
$expectedSettings->showProgress = false;
Assert::equal($expectedSettings->showProgress, $settings->showProgress);
}
public function testJsonOutput()
{
$commandLine = './parallel-lint --json .';
$argv = explode(" ", $commandLine);
$settings = Settings::parseArguments($argv);
Assert::equal(Settings::FORMAT_JSON, $settings->format);
}
public function testGitLabOutput()
{
$commandLine = './parallel-lint --gitlab .';
$argv = explode(" ", $commandLine);
$settings = Settings::parseArguments($argv);
Assert::equal(Settings::FORMAT_GITLAB, $settings->format);
}
public function testCheckstyleOutput()
{
$commandLine = './parallel-lint --checkstyle .';
$argv = explode(" ", $commandLine);
$settings = Settings::parseArguments($argv);
Assert::equal(Settings::FORMAT_CHECKSTYLE, $settings->format);
}
public function testExtensions()
{
$commandLine = './parallel-lint -e php,php.dist,phpt .';
$argv = explode(" ", $commandLine);
$settings = Settings::parseArguments($argv);
$expectedSettings = new Settings();
$expectedSettings->extensions = array('php', 'php.dist', 'phpt');
Assert::equal($expectedSettings->extensions, $settings->extensions);
}
public function testFailCallaback()
{
$commandLine = "./parallel-lint --syntax-error-callback ./path/to/my_custom_callback_file.php .";
$argv = explode(" ", $commandLine);
$settings = Settings::parseArguments($argv);
$expectedSettings = new Settings();
$expectedSettings->syntaxErrorCallbackFile = "./path/to/my_custom_callback_file.php";
Assert::equal($expectedSettings->syntaxErrorCallbackFile, $settings->syntaxErrorCallbackFile);
}
}
$testCase = new SettingsParseArgumentsTest;
$testCase->run();