-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGetOptionsTest.php
More file actions
61 lines (53 loc) · 1.8 KB
/
GetOptionsTest.php
File metadata and controls
61 lines (53 loc) · 1.8 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
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use Smeghead\PhpVariableHardUsage\Option\GetOptions;
class GetOptionsTest extends TestCase
{
public function testEmpty(): void
{
$argv = ['script.php'];
$sut = new GetOptions($argv);
$result = $sut->parse();
$this->assertSame([], $result->paths);
}
public function testHelp(): void
{
$argv = ['script.php', '--help'];
$sut = new GetOptions($argv);
$result = $sut->parse();
$this->assertArrayHasKey('help', $result->options);
$this->assertSame(true, $result->options['help']);
}
public function testVersion(): void
{
$argv = ['script.php', '--version'];
$sut = new GetOptions($argv);
$result = $sut->parse();
$this->assertArrayHasKey('version', $result->options);
$this->assertSame(true, $result->options['version']);
}
public function testSingle(): void
{
$argv = ['script.php', 'single', 'file.php'];
$sut = new GetOptions($argv);
$result = $sut->parse();
$this->assertSame(['single', 'file.php'], $result->paths);
}
public function testScopes(): void
{
$argv = ['script.php', 'scopes', 'dir1', 'dir2'];
$sut = new GetOptions($argv);
$result = $sut->parse();
$this->assertSame(['scopes', 'dir1', 'dir2'], $result->paths);
}
public function testCheckWithThreshold(): void
{
$argv = ['script.php', 'check', 'dir1', 'dir2', '--threshold=200'];
$sut = new GetOptions($argv);
$result = $sut->parse();
$this->assertSame(['check', 'dir1', 'dir2'], $result->paths);
$this->assertArrayHasKey('threshold', $result->options);
$this->assertSame('200', $result->options['threshold']);
}
}