ArgParserTest   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 43
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A testInvalidAlphaArgs() 0 5 1
A testAlphaArgs() 0 3 1
A setUp() 0 10 1
A testInvalidNumericalArg() 0 5 1
A testNumericArgs() 0 4 1
A testArgumentsWithValues() 0 3 1
1
<?php
2
namespace exussum12\CoverageChecker\tests;
3
4
use PHPUnit\Framework\TestCase;
5
use exussum12\CoverageChecker\ArgParser;
6
use exussum12\CoverageChecker\Exceptions\ArgumentNotFound;
7
8
class ArgParserTest extends TestCase
9
{
10
    protected $parser;
11
12
    public function setUp()
13
    {
14
        $args = [
15
            'file.php',
16
            '--some-opt=some-val',
17
            'file',
18
            '-a',
19
            'file2',
20
        ];
21
        $this->parser = new ArgParser($args);
22
    }
23
    public function testNumericArgs()
24
    {
25
        $this->assertSame("file", $this->parser->getArg(1));
26
        $this->assertSame("file2", $this->parser->getArg(2));
27
    }
28
29
    public function testInvalidNumericalArg()
30
    {
31
        $this->expectException(ArgumentNotFound::class);
32
33
        $this->parser->getArg(3);
34
    }
35
36
    public function testAlphaArgs()
37
    {
38
        $this->assertSame("1", $this->parser->getArg('a'));
39
    }
40
41
    public function testInvalidAlphaArgs()
42
    {
43
        $this->expectException(ArgumentNotFound::class);
44
45
        $this->parser->getArg('non-existent');
46
    }
47
48
    public function testArgumentsWithValues()
49
    {
50
        $this->assertEquals('some-val', $this->parser->getArg('some-opt'));
51
    }
52
}
53