-
-
Notifications
You must be signed in to change notification settings - Fork 102
Expand file tree
/
Copy pathParallelTest.php
More file actions
104 lines (85 loc) · 2.67 KB
/
ParallelTest.php
File metadata and controls
104 lines (85 loc) · 2.67 KB
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
<?php
/**
* Tests for the \PHP_CodeSniffer\Config parallel value.
*
* @copyright 2025 PHPCSStandards and contributors
* @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/HEAD/licence.txt BSD Licence
*/
namespace PHP_CodeSniffer\Tests\Core\Config;
use PHP_CodeSniffer\Config;
use PHP_CodeSniffer\Tests\Core\Config\AbstractRealConfigTestCase;
/**
* Tests for the \PHP_CodeSniffer\Config parallel value.
*
* @covers \PHP_CodeSniffer\Config::processLongArgument
* @covers \PHP_CodeSniffer\Config::restoreDefaults
*/
final class ParallelTest extends AbstractRealConfigTestCase
{
/**
* Test that parallel defaults to 1 when no value is provided.
*
* @return void
*/
public function testParallelDefault()
{
$config = new Config(['--standard=PSR1']);
$this->assertSame(1, $config->parallel);
}
/**
* Test that parallel can be set from a CLI argument.
*
* @return void
*/
public function testParallelCanBeSetFromCLI()
{
$_SERVER['argv'] = [
'phpcs',
'--standard=PSR1',
'--parallel=8',
];
$config = new Config();
$this->assertSame(8, $config->parallel);
}
/**
* Test that parallel can be set from a CodeSniffer.conf file.
*
* @return void
*/
public function testParallelCanBeSetFromConfFile()
{
$this->setStaticConfigProperty('configData', ['parallel' => '4']);
$config = new Config(['--standard=PSR1']);
$this->assertSame(4, $config->parallel);
}
/**
* Test that "auto" passed on the CLI resolves to a non-0 positive integer.
*
* @return void
*/
public function testParallelInputHandlingForAutoFromCLI()
{
$_SERVER['argv'] = [
'phpcs',
'--standard=PSR1',
'--parallel=auto',
];
$config = new Config();
// Can't test the exact value as "auto" will resolve differently depending on the machine running the tests.
$this->assertIsInt($config->parallel);
$this->assertGreaterThan(0, $config->parallel);
}
/**
* Test that "auto" set in the CodeSniffer.conf file resolves to a non-0 positive integer.
*
* @return void
*/
public function testParallelInputHandlingForAutoFromConfFile()
{
$this->setStaticConfigProperty('configData', ['parallel' => 'auto']);
$config = new Config(['--standard=PSR1']);
// Can't test the exact value as "auto" will resolve differently depending on the machine running the tests.
$this->assertIsInt($config->parallel);
$this->assertGreaterThan(0, $config->parallel);
}
}